Eager load associations in admin and API collection endpoints#6504
Open
ikraamg wants to merge 1 commit into
Open
Eager load associations in admin and API collection endpoints#6504ikraamg wants to merge 1 commit into
ikraamg wants to merge 1 commit into
Conversation
Several index and show endpoints rendered per-row associations that were not eager loaded, so the query count grew with the number of rows: - solidus_admin products index: the stock column reads total_on_hand, loading each variant's stock items and their stock location - solidus_admin stock items index: each row loads its variant, the variant's product, images, option values, and the stock location - API stock movements index: each movement renders its stock item and the variant graph the listing shows (product, prices, stock, images, option values) - API users index: each user renders its billing and shipping address - admin order payments list: each payment renders its payment method Eager load the associations each view renders so the queries are batched.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6504 +/- ##
=======================================
Coverage 89.68% 89.69%
=======================================
Files 993 993
Lines 20863 20864 +1
=======================================
+ Hits 18712 18713 +1
Misses 2151 2151 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A few admin and API list endpoints render per-row associations that were not eager loaded, so the query count grew with the number of rows. This eager loads what each view already renders.
Each fix is a controller-level includes. The specs assert the relevant table is loaded in a single batched query as the number of rows grows.