Skip to content

fix: run the board query's eager loads once across all columns and lanes - #222

Merged
ManukMinasyan merged 3 commits into
4.xfrom
fix/batch-column-eager-loads
Oct 31, 2026
Merged

ManukMinasyan merged 3 commits into
4.xfrom
fix/batch-column-eager-loads

Conversation

@ManukMinasyan

@ManukMinasyan ManukMinasyan commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

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() and getLaneRecords() keep their signatures and behaviour. formatLane() now receives the lane's records instead of fetching them.

Measured in Relaticle

Board Before After
Opportunities, 10 stages 82 queries 28 queries
Tasks, 3 statuses 29 queries 19 queries

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.

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
@ManukMinasyan
ManukMinasyan merged commit d7a3cb2 into 4.x Oct 31, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant