Repository navigation
Description
Bug description
Since 7.10.0 (#29004, "eagerly evaluating plans with one unconditional database operation"), every result of a single-query plan is walked and copied one extra time in JavaScript. Large findMany results cost ~10% more CPU and ~11% more allocation than on 7.9.1, with identical SQL and identical database time.
Where it happens (7.10.1, runtime/client.js): run() calls the new fast path (jd()), which runs the query and substitutes its result into the remaining plan as { type: "value", args: rows }. The interpreter's value case then calls evaluateArg (de) on args; for an array that is rows.map(r => evaluateArg(r, …)) — one extra call per row (plus two prisma__type property checks) and a full copy of the result array, for a value that is already final.
Proof: in a local copy of 7.10.1, replacing
o=jd(t,a=>this.interpretNode(a,i))?.catch(a=>Be(a)); with o=void 0; (i.e. skipping only the fast path) brings CPU and allocation back to 7.9.1 exactly (table below). Small queries were no slower with the fast path removed in our measurements.
Measurements
findMany({ where: { parent: { ownerId, deletedAt: null } }, select: { id: true } }) returning 294,000 rows (text ids), Postgres 16.14 local, @prisma/adapter-pg, prisma-client-js, Node 25.5, pg 8.18.0 in every install. Process CPU per call (process.cpuUsage), median of 3 rounds after warm-up:
| version | CPU ms / call |
|---|---|
| 7.2.0 | 141.5 |
| 7.3.0 | 143.4 |
| 7.4.2 | 141.2 |
| 7.5.0 | 142.2 |
| 7.6.0 | 140.8 |
| 7.7.0 | 139.8 |
| 7.8.0 | 141.4 |
| 7.9.1 | 141.3 |
| 7.10.0 | 157.3 |
| 7.10.1 | 153.8 |
| build | MB allocated / call | CPU ms / call |
|---|---|---|
| 7.9.1 | 153.8 | 140.2 / 141.7 / 142.2 |
| 7.10.1 stock | 170.6 | 153–159 |
| 7.10.1 with the fast path disabled | 153.8 | 135.7 / 139.1 / 141.4 |
- The emitted SQL is byte-identical on 7.9.1 and 7.10.1 (one
LEFT JOIN … WHERE … OFFSET $2), and thequeryevent reports the same database time (92–99 ms) on both. - Most of the extra process CPU shows up as GC: scavenge background/parallel time +~9 ms per call; with
--single-threaded-gcthe gap shrinks from ~14 ms to ~6 ms.
Second observation (present in 7.2 through 7.10.1): relation lookups bind un-deduplicated foreign keys
findMany over 40,000 rows with include: { worker: { select: { id, name } }, job: { select: { id, title } } } sends, per relation, one IN with every row's foreign key — chunked at 32,766 — instead of the distinct set:
worker: 32,766 + 7,236 bind parameters for 13 distinct idsjob: 32,766 + 7,236 bind parameters for 5,001 distinct ids
That is 4 extra statements and ~70 ms of database wall time per call that a Set over the keys would avoid. (On 7.10 each chunk pair is additionally wrapped in a transaction.)
Suggested fix
- Mark the substituted node as an already-evaluated literal (or return the rows without passing them through
evaluateArg). - De-duplicate the parent keys before binding a relation lookup's
INlist.
How to reproduce
- Postgres table with ~300k rows reachable through a to-one relation filter.
- Time
findMany({ where: { rel: { … } }, select: { id: true } })withprocess.cpuUsage()on 7.9.1 and on 7.10.0+ (same Node, same pg). - Optionally, comment out the
jd()fast-path call inruntime/client.json 7.10.x and re-run.
Happy to provide the full harness.
Prisma information
- prisma / @prisma/client / @prisma/adapter-pg: 7.10.1 (bisected 7.2.0 → 7.10.1)
- generator
prisma-client-js, no preview features - Postgres 16.14, macOS (arm64), Node 25.5
Activity
prisma-asks commentedon Nov 8, 2026
Thanks for reporting this. We're looking into it now: whether we can reproduce it and what impact it has.
You can follow where this stands here: https://asks.prisma.cool/public/asks/01a130e6-1c4d-734b-a6f2-5b271c73cce6
You can follow where this stands here: https://asks.prisma.cool/public/asks/01a1b958-a3c8-71e4-853a-e71e2acf14ea
fix(client-engine-runtime): prevent in-place mutation on reverse of p…
wmadden-electric commentedon Nov 20, 2026
Fixed on
v7by #30986.perf(client-engine-runtime): avoid copying result rows when evaluatin…