Skip to content

Commit

Permalink
Update 100-query-optimization-performance.mdx (#5975)
Browse files Browse the repository at this point in the history
* Update 100-query-optimization-performance.mdx

* Update content/200-orm/200-prisma-client/100-queries/100-query-optimization-performance.mdx
  • Loading branch information
nikolasburk authored May 3, 2024
1 parent 287387f commit a07bdba
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ The n+1 problem occurs when you loop through the results of a query and perform

</div>

The Prisma Client dataloader automatically **batches** `findUnique()` queries that ✔ occur in the same tick and ✔ have the same `where` and `include` parameters.
The Prisma Client dataloader automatically _batches_ `findUnique()` queries that occur in the same [tick](https://nodejs.org/en/learn/asynchronous-work/event-loop-timers-and-nexttick#processnexttick) and have the same `where` and `include` parameters if:

- All criteria of the `where` filter are on scalar fields (unique or non-unique) of the same model you're querying.
- All criteria use the `equal` filter, whether that's via the shorthand or explicit syntax `(where: { field: <val>, field1: { equals: <val> } })`.
- No boolean operators or relation filters are present.

Automatic batching of `findUnique()` is particularly useful in a **GraphQL context**. GraphQL runs a separate resolver function for every field, which can make it difficult to optimize a nested query.

Expand Down

0 comments on commit a07bdba

Please sign in to comment.