Skip to content

test(relations): add explicit N+1 query-count assertions#61

Merged
benkhalife merged 1 commit into
mainfrom
fix/eager-loading-with-after-select-and-orderby
Jun 30, 2026
Merged

test(relations): add explicit N+1 query-count assertions#61
benkhalife merged 1 commit into
mainfrom
fix/eager-loading-with-after-select-and-orderby

Conversation

@benkhalife

Copy link
Copy Markdown
Member

Adds tests that measure actual SQL query counts via DB::getQueryLog() to confirm eager loading (with()) issues a constant 2 queries regardless of parent row count — not one query per row — across hasMany, belongsTo, and the select()->with() chain. Includes a lazy- loading baseline test to make the N+1 contrast explicit rather than just asserting the eager case in isolation.

Adds tests that measure actual SQL query counts via DB::getQueryLog()
to confirm eager loading (with()) issues a constant 2 queries
regardless of parent row count — not one query per row — across
hasMany, belongsTo, and the select()->with() chain. Includes a lazy-
loading baseline test to make the N+1 contrast explicit rather than
just asserting the eager case in isolation.
@benkhalife
benkhalife merged commit 092d018 into main Jun 30, 2026
11 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