# X_N_PLUS_ONE_QUERY

## Means

a read repeated once per row

## Typical cause

one lookup per row of a page — `members.findById` fifty times where one `in` statement would answer. Counted per request by the statement ledger `x dev` installs, and never counted in production. Reported on four surfaces at once: `x dev`'s findings, `/_x/timeline`'s `nPlusOne`, the browser overlay under the error, and one `logger.warn` per request per code. **Thrown in one place only** — a test that destructures `@ultimat3/testing`'s `statements` fixture, where the loop's fifth statement rejects and fails the test

## Fix

the `fix` is the preload the schema already declares, e.g. `db.posts.preload('author')`. No relation points at the entity ⇒ the batched form of the same read, `db.members.andWhere('id', 'in', ids).all()`. A loop that is genuinely one statement per row is declared, not silenced: `expectedQueryLoop('<why>', fn)`

[Entity and database](/error-codes#entity-and-database)
