Skip to content

Eager load line item details on the admin order page to avoid N+1s#6500

Open
ikraamg wants to merge 1 commit into
solidusio:mainfrom
ikraamg:perf/admin-order-show-eager-load
Open

Eager load line item details on the admin order page to avoid N+1s#6500
ikraamg wants to merge 1 commit into
solidusio:mainfrom
ikraamg:perf/admin-order-show-eager-load

Conversation

@ikraamg

@ikraamg ikraamg commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

The admin order page loaded each line item's variant, product, images and option values lazily while rendering the cart, so the page's query count grew with the number of line items on the order.

  • eager loads each line item's variant, product, variant images and option values
  • the page's query count stays constant regardless of order size
  • adds a request spec asserting the page renders and loads line item variants in a single query

The admin order page rendered each line item's variant, product, images
and option values lazily, so the query count grew with the number of
items in the order.

Eager loading those associations keeps the page's query count constant
regardless of how many line items the order has.
Comment thread admin/app/controllers/solidus_admin/orders_controller.rb
Comment thread admin/spec/requests/solidus_admin/orders_spec.rb
Comment thread admin/spec/requests/solidus_admin/orders_spec.rb
Comment thread admin/spec/requests/solidus_admin/orders_spec.rb
Comment thread admin/spec/requests/solidus_admin/orders_spec.rb
Comment thread admin/spec/requests/solidus_admin/orders_spec.rb
Comment thread admin/spec/requests/solidus_admin/orders_spec.rb
Comment thread admin/spec/requests/solidus_admin/orders_spec.rb
Comment thread admin/spec/requests/solidus_admin/orders_spec.rb
@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.68%. Comparing base (8d781ac) to head (798c60d).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6500   +/-   ##
=======================================
  Coverage   89.68%   89.68%           
=======================================
  Files         993      993           
  Lines       20863    20863           
=======================================
  Hits        18712    18712           
  Misses       2151     2151           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ikraamg ikraamg marked this pull request as ready for review June 26, 2026 06:35
@ikraamg ikraamg requested a review from a team as a code owner June 26, 2026 06:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants