Repository navigation
fix: run the board query's eager loads once across all columns and lanes - #222
Merged
Merged
Conversation
Each column fetched its cards with its own query, so every relation the board query eager loads ran once per column. A board with ten columns loaded the same relations ten times. Columns now fetch their cards without eager loads, and the loads run once over all of them. Amp-Thread-ID: https://ampcode.com/threads/T-01a191af-73a8-74ec-88f0-93868fe01c45
Grouped boards fetch each lane with its own query, so the board query's eager loads ran once per lane. Lanes now fetch their cards without eager loads, and the loads run once over every visible lane. Amp-Thread-ID: https://ampcode.com/threads/T-01a191af-73a8-74ec-88f0-93868fe01c45
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.
Why
Each board column, and each swimlane on a grouped board, fetches its cards with its own query. Every relation the board query eager loads therefore ran once per column or lane. In Relaticle, a 10-stage opportunities board loaded the same custom field values, fields, options, companies and media 10 times: 82 queries for one render. Sentry flagged it as an N+1.
Change
Columns and lanes now fetch their cards with the eager loads stripped, then run the loads once over all fetched cards.
getBoardRecords()andgetLaneRecords()keep their signatures and behaviour.formatLane()now receives the lane's records instead of fetching them.Measured in Relaticle
One card query per column remains, because each column pages on its own.
Tests
Two tests in
GroupingTest(columns and lanes) fail without the fix, with 2 and 3 relation queries instead of 1, and check that every card still carries its own related records. Released fixtures are untouched, so the classic gate passes. Full suite: 661 passed.