Benchmarks
Every number below comes from an orders table with 200,000 rows, measured without HTTP: the engine's own cost, not your API's latency. Timings are medians of ten runs from one client, unless the section is about load.
What a request costs
Returning a page is almost free, even 180,000 rows deep with a cursor. What you pay for is counting: an exact total reads every matching row, and facets group them again. Leave both off when the screen doesn't show them.
Yellow: no count and no facets.
Facets on the root table share one GROUPING SETS statement. Facets that read relations need their own, which is why five mixed facets cost more than three root ones. See Performance for what to do about each.
Under load
With 32 callers sharing 10 pooled connections, and PostgreSQL held to 4 CPUs, a plain page serves about 11,500 requests a second. Counting is again what limits you: an exact count brings that to about 730, and five facets to about 19.
20 rounds of 32 requests each. Yellow: no count and no facets.
The gap is the amount of work. A page walks the sort index, takes 50 rows and stops; each facet reads and groups all 200,000. With 4 CPUs, that works out to at most about 0.35 ms of database CPU per page, against about 210 ms per five-facet request. Pages and cursors stay under 10 ms at p95 with the pool fully busy. Facet requests are the ones to cache, defer, or tune before you add connections.
Searching through relations
A search on related fields, like customer.name, can join every order to its customer, or find the matching customers first. The engine asks PostgreSQL which plan is cheaper and picks it.
Measured on September 21, 2026, when the engine started picking the plan.
Rare terms get 13 to 21 times faster. Common terms match on the first rows anyway, so asking for the plan just adds about 1 ms.
Exporting every row
Paging through the same rows re-runs the whole selection for every page of 1,000. scan() keeps one cursor open instead, and the gap grows with the cost of the sort.
A scan holds a connection and a snapshot until your consumer finishes.
Since version 2.4.1
The same requests on version 2.4.1 (September 2026), measured in the same run: before the engine learned to skip redundant joins, share facet statements and seek straight to a cursor.
Details
The harness, tools/benchmark-postgres.ts, creates 200,000 orders and 20,000 accounts with indexes on joins, sorts and searched text, checks that both versions return the same results, then alternates their runs: ten samples per request after a warm-up. PostgreSQL 18, work_mem 4 MB.
TEST_DATABASE_URL=postgres://… \
BENCH_BASELINE_MODULE=…/drizzle-resource@2.4.1/build/index.js \
bun run benchmark:postgres
BENCH_ROWS and BENCH_ITERATIONS change the size, BENCH_CONCURRENCY sends several requests at once (the load section used 32, with the database container limited to 4 CPUs and one request type per process), BENCH_SCAN=1 adds the full-export comparison, and BENCH_OUTPUT writes the JSON results. Raw samples are in tools/results.
Searching every field, numbers included, can't use the indexed rewrite. A common term finds a page fast; a rare one reads the whole selection.
| Term | No count | Exact count | Count + 5 facets |
|---|---|---|---|
rare, 19999 | 144 ms | 321 ms | 392 ms |
common, account | 7.0 ms | 194 ms | 346 ms |
| no match | 131 ms | 172 ms | 274 ms |
An older engine on about 100,000 rows, at 10 to 50 concurrent connections. It shows which tuning pays off first, not today's capacity.
| Step | Effect |
|---|---|
| Indexes on join, sort, filter | about 8× throughput, p99 down 83 to 87% |
Hand-written strategy.ids | about 12× throughput over that engine |
Hand-written strategy.facets | mostly helps many-to-many facets |
Faster pages send more traffic to the facet aggregates, and a many-to-many facet stayed above 2 s at 10 connections whatever the ids step did.