# PostgreJS Benchmarks (Bun)
_Generated by `npm run bench:report`. Do not hand-edit — re-run the command instead._
## Contents
- [Methodology](#methodology)
- [Reading a table](#reading-a-table)
- [The columns](#the-columns)
- [Where the comparison is not like-for-like](#where-the-comparison-is-not-like-for-like)
- [Environment](#environment)
- [Connection](#connection)
- [Connect](#connect)
- [Simple Query](#simple-query)
- [Sequential Execution](#sequential-execution)
- [Concurrent Execution](#concurrent-execution)
- [Simple Query Fetch](#simple-query-fetch)
- [Extended Query](#extended-query)
- [Sequential Execution](#sequential-execution-1)
- [Concurrent Execution](#concurrent-execution-1)
- [Mixed-Type Decode (Text Protocol)](#mixed-type-decode-text-protocol)
- [Mixed-Type Decode (Binary Protocol)](#mixed-type-decode-binary-protocol)
- [Large Blob Fetch](#large-blob-fetch)
- [Large Array Fetch](#large-array-fetch)
- [Prepared Statement Reuse (Sequential)](#prepared-statement-reuse-sequential)
- [Prepared Statement Reuse (Concurrent)](#prepared-statement-reuse-concurrent)
- [Unit of Work](#unit-of-work)
- [Unit of Work](#unit-of-work-1)
- [Bulk Load](#bulk-load)
- [Bulk Load (text COPY)](#bulk-load-text-copy)
- [Bulk Load (binary COPY)](#bulk-load-binary-copy)
- [Cursor Streaming](#cursor-streaming)
- [Cursor Streaming](#cursor-streaming-1)
- [Connection Pooling](#connection-pooling)
- [Pooled Simple Query](#pooled-simple-query)
- [Pooled Extended Query](#pooled-extended-query)
- [Raw data](#raw-data)
## Methodology
These numbers come from `benchmark/` (`npm run bench`), comparing PostgreJS against `pg` (node-postgres) and `postgres` (postgres.js) against the same server, on the same machine, with the same workload. Each scenario is written once per library, using that library's own fastest calling convention - only the mechanism differs, never the work. [benchmark/README.md](./benchmark/README.md) says how to reproduce them.
Each `(library, scenario)` pair runs in a child process of its own, one at a time, three times over; the tables report the median of the three.
### Reading a table
Rows are in a fixed library order rather than fastest-first, so a library sits in the same place in every scenario. A **bolded** value is the best one *or tied with it* - the tie band is how far the leader's own repeats of that column moved, so nothing is called slower than the noise the leader itself shows.
What survives a re-run is the ordering, not the absolute numbers: the same scenario on the same machine, hours later, has been seen to move by 2x. Read a row against the rows beside it, and not against a table of another date.
### The columns
| Column | What it answers |
| --- | --- |
| `GC (ms/op)` | Time spent collecting, per call - how much garbage the library's own path makes. |
| `Peak Heap (KB)` | The most `heapUsed + external` ever stood above a forced-GC baseline during the run. Not what one call needs: it also holds whatever earlier calls left uncollected. `external` counts because the payload usually lives there - a `Buffer`, and a large string built from one, are both off-heap. |
| `Retained (KB)` | What is still held once the run ends. A working set, not a footprint: left idle, both this client's buffers and the others' pools fall back to nothing within seconds. |
| `Net in/out (KB/op)` | Bytes across the socket each way. Only on the four scenarios whose payload is the point - the two large fetches and the two Bulk Loads - since everywhere else it is small and identical across libraries. |
Memory figures are noisier than latency ones; read them as a direction rather than to their last digit. Under Bun, `GC (ms/op)` is blank: `PerformanceObserver` never reports a `gc` entry there. Peak Heap is unaffected.
### Where the comparison is not like-for-like
Deliberate, and worth knowing before reading a row:
- **Cursor streaming**: `pg` has no cursor API of its own, so its scenario emulates one with `DECLARE`/`FETCH`.
- **Bulk Load (binary COPY)** has one row: only this client can produce the format. Read it against Bulk Load (text COPY), where all three format the same CSV and the ranking is a ranking of drivers.
- **Row shape**: PostgreJS is set to `objectRows: true` everywhere so its rows match what the others return by default. The one normalisation in the suite.
- **Type decoding**: no custom parsers or overrides anywhere - each library decodes as it does out of the box, which is what a caller gets.
- **Pooling, pipelining and prepared statements**: each library uses its own mechanism and its own defaults. The numbers compare libraries as they ship, not one dial turned for all three.
- **One PostgreJS default is turned off**: `asyncErrorHandling`, which captures a caller-preserving async stack on every call so a failure points at the line that made it. `pg` and `postgres.js` have no equivalent, so leaving it on would charge one library for a feature the others do not offer. It stays on by default in the library; it is off only here, and it is worth about 0.5-1.0 KB a call on a small statement.
- **`pg-native`** is out of scope: it needs a system libpq and native compilation, which CI cannot assume. It could be added later behind its own flag.
- A scenario that needs more warmup or more repeats than the rest says so in its own description.
## Environment
- Run date: 2026-10-05T17:29:57.704Z
- Runtime: Bun 1.4.2
- OS: Darwin 25.6.0 (darwin/arm64)
- CPU: Apple M5 Pro (18 logical cores)
- RAM: 48.0 GB total
- PostgreSQL: PostgreSQL 18.6 on aarch64-unknown-linux-musl, compiled by gcc (Alpine 15.2.0) 15.2.0, 64-bit
- Library versions (installed, not this repo's semver range): Bun.sql 1.4.2, pg (node-postgres) 8.23.0, PostgreJS 3.12.0, postgres (postgres.js) 3.4.9
## Connection
The fixed cost of opening (and closing) a connection - the TCP handshake, PostgreSQL startup/auth handshake, and `ReadyForQuery`, paid once per connection lifetime rather than once per query.
### Connect
Open a fresh connection/session and close it, repeated per sample
| Library | Mean (ms) | p75 (ms) | p99 (ms) | ops/sec | vs. slowest | GC (ms/op) | Peak Heap (KB) | Retained (KB) |
|---|---:|---:|---:|---:|---:|---:|---:|---:|
| PostgreJS (3.12.0) | ***2.011*** | ***2.069*** | ***2.814*** | ***499.7*** | ***3.81x*** | — | 3859.73 | 3452.91 |
| pg (node-postgres) (8.23.0) | 2.899 | 2.955 | 3.809 | 346.8 | 2.64x | — | 140.25 | 2851.56 |
| postgres (postgres.js) (3.4.9) | 7.667 | 7.784 | 9.541 | 130.9 | 1.00x | — | 4663.87 | 3463.49 |
| Bun.sql (1.4.2) | 2.887 | 2.950 | 3.282 | 347.2 | 2.66x | — | ***0.00*** | ***1602.83*** |
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Mean latency (ms, lower is better)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "ms" 0.0000 --> 11.5011
bar [2.0115, 2.8993, 7.6674, 2.8875]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}, 'themeVariables': {'xyChart': {'plotColorPalette': '#f2a900'}}}}%%
xychart-beta
title "Throughput (ops/sec, higher is better)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "ops/sec" 0.0000 --> 749.6046
bar [499.7364, 346.7577, 130.8508, 347.1624]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Peak heap growth (KB, max memory reached)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "KB" 0.0000 --> 6995.8008
bar [3859.7266, 140.2500, 4663.8672, 0.0000]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Retained heap (KB, still held after the run)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "KB" 0.0000 --> 5195.2354
bar [3452.9102, 2851.5645, 3463.4902, 1602.8320]
```
## Simple Query
PostgreSQL's Simple Query sub-protocol: the client sends the SQL text as a single `Query` (`Q`) message and the server parses, plans, executes, and streams the results back in that same round trip - no separate parse/bind/describe/execute/sync steps, and no query parameters. In postgrejs this is `Connection.execute(sql)`. It's the cheapest way to run a query the client isn't going to reuse, which is why it's also the baseline every other protocol group below is compared against. It's distinct from the Extended Query group below: Extended Query trades this single round trip for several (parse, bind, describe, execute, sync) in exchange for bind parameters and a statement the server can plan once and re-execute. The scenarios here measure that Simple Query round trip three ways: a single query on an otherwise-idle connection, many queries fired concurrently over one connection, and one query that fetches many rows.
### Sequential Execution
Run `select 1` one call at a time on an already-open connection.
Each call is fully awaited before the next one starts.
Every library uses its genuine Simple Query path: PostgreJS's execute(),
pg's query(text) with no params, postgres.js's unsafe() with no args -
always a real Simple Query message, regardless of any prepare option.
This is the baseline for the group: one round trip's plain cost, with no
concurrency, no pooling, and no bind parameters. Compare it against
Concurrent Execution below to see what overlapping calls on the same
connection buys each library.
| Library | Mean (ms) | p75 (ms) | p99 (ms) | ops/sec | vs. slowest | GC (ms/op) | Peak Heap (KB) | Retained (KB) |
|---|---:|---:|---:|---:|---:|---:|---:|---:|
| PostgreJS (3.12.0) | ***0.201*** | ***0.203*** | ***0.326*** | ***5066.1*** | ***1.05x*** | — | 5399.55 | 1914.10 |
| pg (node-postgres) (8.23.0) | ***0.202*** | ***0.199*** | 0.362 | ***5160.5*** | ***1.05x*** | — | 8703.78 | 1475.10 |
| postgres (postgres.js) (3.4.9) | ***0.199*** | ***0.200*** | 0.356 | ***5146.7*** | ***1.06x*** | — | 12250.21 | 1344.42 |
| Bun.sql (1.4.2) | 0.211 | ***0.205*** | ***0.328*** | ***5015.1*** | 1.00x | — | ***1241.45*** | ***890.73*** |
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Mean latency (ms, lower is better)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "ms" 0.0000 --> 0.3168
bar [0.2007, 0.2018, 0.1989, 0.2112]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}, 'themeVariables': {'xyChart': {'plotColorPalette': '#f2a900'}}}}%%
xychart-beta
title "Throughput (ops/sec, higher is better)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "ops/sec" 0.0000 --> 7740.8105
bar [5066.0619, 5160.5404, 5146.6658, 5015.0797]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Peak heap growth (KB, max memory reached)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "KB" 0.0000 --> 18375.3179
bar [5399.5508, 8703.7754, 12250.2119, 1241.4512]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Retained heap (KB, still held after the run)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "KB" 0.0000 --> 2871.1553
bar [1914.1035, 1475.0996, 1344.4160, 890.7344]
```
### Concurrent Execution
The concurrent counterpart to Sequential Execution above. Fire
100 Simple Query calls on the SAME
already-open connection without awaiting each one individually, then await
them all via Promise.all().
PostgreJS pipelines these at the wire level: it writes each message without
waiting for the previous one's response, then matches responses back in
FIFO order, so results never cross-talk even though the caller never
awaited between calls.
Each call selects a distinct literal and checks the result against it, so
this scenario verifies correctness too - do the other libraries' single
connections queue/pipeline correctly? - not just timing. Without distinct
values every response would be interchangeable and a client that matched
them back to the wrong caller would still return a valid row for each,
reporting a fast but wrong number instead of failing.
The distinct literal costs nothing on the server and does not turn this
into a measurement of statement preparation: the Simple Query protocol has
no server-side statement cache, so PostgreSQL parses, rewrites and plans
every Query message it receives even when the text is byte-identical to
the previous one. Measured, 100 concurrent calls with a constant literal
land within noise of the varying one (Node -2.5% to +1.5% across repeats,
Bun +0.3% - the sign flips between runs). Simple Query has no bind
parameters to carry the distinct value instead, which is why this varies
the text where the Extended Query counterpart varies a parameter. (concurrency=100)
| Library | Mean (ms) | p75 (ms) | p99 (ms) | ops/sec | vs. slowest | GC (ms/op) | Peak Heap (KB) | Retained (KB) |
|---|---:|---:|---:|---:|---:|---:|---:|---:|
| PostgreJS (3.12.0) | ***1.955*** | ***1.995*** | 3.664 | ***524.8*** | ***10.95x*** | — | 15546.93 | 1876.65 |
| pg (node-postgres) (8.23.0) | 1.998 | 2.058 | ***2.921*** | ***515.7*** | 10.71x | — | 18228.43 | 1415.47 |
| postgres (postgres.js) (3.4.9) | ***1.887*** | ***1.949*** | ***2.924*** | ***539.4*** | ***11.34x*** | — | 16728.73 | 1301.57 |
| Bun.sql (1.4.2) | 21.402 | 21.355 | 32.982 | 48.3 | 1.00x | — | ***10027.60*** | ***775.64*** |
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Mean latency (ms, lower is better)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "ms" 0.0000 --> 32.1037
bar [1.9550, 1.9981, 1.8873, 21.4025]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}, 'themeVariables': {'xyChart': {'plotColorPalette': '#f2a900'}}}}%%
xychart-beta
title "Throughput (ops/sec, higher is better)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "ops/sec" 0.0000 --> 809.1405
bar [524.7895, 515.7327, 539.4270, 48.3230]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Peak heap growth (KB, max memory reached)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "KB" 0.0000 --> 27342.6387
bar [15546.9336, 18228.4258, 16728.7285, 10027.5977]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Retained heap (KB, still held after the run)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "KB" 0.0000 --> 2814.9814
bar [1876.6543, 1415.4727, 1301.5703, 775.6406]
```
### Simple Query Fetch
Fetch 1000 mixed-type rows via each
library's Simple Query path - the same protocol as Sequential Execution and
Concurrent Execution above - on a single already-open connection, no pool.
This measures row-fetch throughput without the parse/bind/describe
overhead of the Extended Query protocol.
Excludes int8: pg, postgres.js and PostgreJS return it as genuinely
different JS types by default (string, BigInt, number-or-BigInt). Timing
that column would measure type-conversion choice, not decode speed. (rowTarget=1000)
| Library | Mean (ms) | p75 (ms) | p99 (ms) | ops/sec | vs. slowest | GC (ms/op) | Peak Heap (KB) | Retained (KB) |
|---|---:|---:|---:|---:|---:|---:|---:|---:|
| PostgreJS (3.12.0) | 1.169 | 1.377 | 2.104 | 903.2 | 1.38x | — | 23285.83 | 2296.85 |
| pg (node-postgres) (8.23.0) | 1.616 | 1.898 | 2.706 | 645.0 | 1.00x | — | 17372.72 | 1610.86 |
| postgres (postgres.js) (3.4.9) | 1.473 | 1.746 | 2.617 | 714.4 | 1.10x | — | 16474.97 | 1778.58 |
| Bun.sql (1.4.2) | ***1.065*** | ***1.154*** | ***1.811*** | ***981.2*** | ***1.52x*** | — | ***11170.50*** | ***1101.07*** |
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Mean latency (ms, lower is better)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "ms" 0.0000 --> 2.4241
bar [1.1685, 1.6161, 1.4728, 1.0653]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}, 'themeVariables': {'xyChart': {'plotColorPalette': '#f2a900'}}}}%%
xychart-beta
title "Throughput (ops/sec, higher is better)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "ops/sec" 0.0000 --> 1471.8550
bar [903.1574, 644.9697, 714.4427, 981.2367]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Peak heap growth (KB, max memory reached)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "KB" 0.0000 --> 34928.7466
bar [23285.8311, 17372.7227, 16474.9746, 11170.4980]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Retained heap (KB, still held after the run)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "KB" 0.0000 --> 3445.2773
bar [2296.8516, 1610.8633, 1778.5781, 1101.0742]
```
## Extended Query
PostgreSQL's Extended Query sub-protocol: the client splits a query into separate `Parse`, `Bind`, `Describe`, `Execute`, and `Sync` messages instead of Simple Query's single `Query` message - more wire round trips per query, but it is what makes bind parameters, typed result columns, and a statement the server plans once and can re-execute possible at all (none of that exists in Simple Query). In postgrejs, `Connection.query(sql)` always goes through this path, and `Connection.prepare(sql)` additionally gives back a reusable `PreparedStatement` handle instead of re-sending `Parse` on every call. The scenarios here mirror the Simple Query group's own Sequential/Concurrent pair - a single parameterized call one at a time, then many fired concurrently over one connection - plus decoding many mixed-type rows through `query()` (the row count itself a bind parameter, large enough that decode work dominates the measurement) on both the text and binary wire formats, and the cost this protocol is meant to amortize away: reusing one prepared statement across many executions, sequentially and then concurrently.
### Sequential Execution
The Extended Query counterpart to the Simple Query group's
Sequential Execution above: one already-open connection, one call at a
time, each awaited before the next starts.
Instead of a literal, it selects an int4 value bound as a real query
parameter (`select $1::int4`), so every library genuinely goes through
Parse/Bind/Describe/Execute/Sync rather than a single Query message.
Unlike Prepared Statement Reuse below, there is no reused or cached
server-side statement here, so this isolates the one-shot per-call cost
Extended Query pays on top of the Simple Query baseline. Compare it
against Concurrent Execution below to see what overlapping calls buys
each library here too.
The cast is `int4`, not a narrower integer type, on purpose. Libraries
differ in whether they declare parameter types at all: PostgreJS names an
OID for every parameter in Parse (int4 for a JS number), while pg and
postgres.js send none and let the server infer each one from context. With
a narrower target - `$1::int2` - that difference stops being free: the
server has to wrap PostgreJS's int4 parameter in a runtime cast that the
others never pay for, and this scenario ends up measuring type-declaration
policy rather than Extended Query speed. Measured with a counterbalanced
A/B/B/A run (each library taking both positions in the pair, so ordering
bias cancels - it is worth ~1.4 points here on its own): against pg,
`$1::int2` put PostgreJS 4.3% behind on average, `$1::int4` 0.5%, which
is inside this measurement's noise. Keep the parameter's declared type and
the cast's target the same.
| Library | Mean (ms) | p75 (ms) | p99 (ms) | ops/sec | vs. slowest | GC (ms/op) | Peak Heap (KB) | Retained (KB) |
|---|---:|---:|---:|---:|---:|---:|---:|---:|
| PostgreJS (3.12.0) | ***0.191*** | ***0.186*** | 0.434 | ***5475.9*** | ***1.14x*** | — | 5407.74 | 2620.25 |
| pg (node-postgres) (8.23.0) | 0.218 | 0.218 | 0.361 | 4861.8 | 1.00x | — | 17881.27 | 1800.97 |
| postgres (postgres.js) (3.4.9) | 0.194 | ***0.188*** | ***0.311*** | ***5423.6*** | 1.12x | — | 9715.43 | 1437.95 |
| Bun.sql (1.4.2) | ***0.190*** | ***0.185*** | 0.375 | ***5506.8*** | ***1.14x*** | — | ***1131.21*** | ***916.13*** |
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Mean latency (ms, lower is better)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "ms" 0.0000 --> 0.3265
bar [0.1913, 0.2176, 0.1940, 0.1902]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}, 'themeVariables': {'xyChart': {'plotColorPalette': '#f2a900'}}}}%%
xychart-beta
title "Throughput (ops/sec, higher is better)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "ops/sec" 0.0000 --> 8260.1950
bar [5475.9467, 4861.8491, 5423.6246, 5506.7966]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Peak heap growth (KB, max memory reached)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "KB" 0.0000 --> 26821.9043
bar [5407.7432, 17881.2695, 9715.4307, 1131.2090]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Retained heap (KB, still held after the run)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "KB" 0.0000 --> 3930.3809
bar [2620.2539, 1800.9746, 1437.9453, 916.1348]
```
### Concurrent Execution
The concurrent counterpart to Sequential Execution above, same
shape as the Simple Query group's Concurrent Execution.
Fire 50 genuine Extended Query
calls (`select $1::int4`, a real bind parameter, not a reused/cached
statement) on the SAME already-open connection without awaiting each one
individually, then await them all via Promise.all(). PostgreJS pipelines
these at the wire level, so results never cross-talk even though the
caller never awaited between calls.
Each call binds a distinct value and checks the result against it, so this
scenario verifies correctness too - do the other libraries' single
connections queue/pipeline Extended Query calls correctly? - not just
timing.
The cast is `int4`, not a narrower integer type, on purpose. Libraries
differ in whether they declare parameter types at all: PostgreJS names an
OID for every parameter in Parse (int4 for a JS number), while pg and
postgres.js send none and let the server infer each one from context. With
a narrower target - `$1::int2` - that difference stops being free: the
server has to wrap PostgreJS's int4 parameter in a runtime cast that the
others never pay for, and this scenario ends up measuring type-declaration
policy rather than Extended Query speed. Measured with a counterbalanced
A/B/B/A run (each library taking both positions in the pair, so ordering
bias cancels - it is worth ~1.4 points here on its own): against pg,
`$1::int2` put PostgreJS 4.3% behind on average, `$1::int4` 0.5%, which
is inside this measurement's noise. Keep the parameter's declared type and
the cast's target the same. (concurrency=50)
| Library | Mean (ms) | p75 (ms) | p99 (ms) | ops/sec | vs. slowest | GC (ms/op) | Peak Heap (KB) | Retained (KB) |
|---|---:|---:|---:|---:|---:|---:|---:|---:|
| PostgreJS (3.12.0) | 0.542 | 0.555 | 1.054 | 1911.7 | 2.14x | — | 14852.08 | 2788.64 |
| pg (node-postgres) (8.23.0) | 1.158 | 1.212 | 1.829 | 877.8 | 1.00x | — | 19711.56 | 1829.53 |
| postgres (postgres.js) (3.4.9) | ***0.460*** | ***0.473*** | ***0.880*** | ***2241.0*** | ***2.52x*** | — | 17670.56 | 1412.42 |
| Bun.sql (1.4.2) | 0.610 | 0.612 | 1.315 | 1708.3 | 1.90x | — | ***11040.09*** | ***861.07*** |
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Mean latency (ms, lower is better)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "ms" 0.0000 --> 1.7373
bar [0.5416, 1.1582, 0.4602, 0.6096]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}, 'themeVariables': {'xyChart': {'plotColorPalette': '#f2a900'}}}}%%
xychart-beta
title "Throughput (ops/sec, higher is better)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "ops/sec" 0.0000 --> 3361.5647
bar [1911.6839, 877.8381, 2241.0431, 1708.3105]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Peak heap growth (KB, max memory reached)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "KB" 0.0000 --> 29567.3467
bar [14852.0820, 19711.5645, 17670.5605, 11040.0879]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Retained heap (KB, still held after the run)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "KB" 0.0000 --> 4182.9551
bar [2788.6367, 1829.5273, 1412.4199, 861.0742]
```
### Mixed-Type Decode (Text Protocol)
Fetch 1000 mixed-type rows (int2/int4/
float4/float8/varchar/json/jsonb/timestamp/timestamptz/bytea) via each
library's Extended Query path - PostgreJS's query(), a one-shot
parameterized call, not a reused prepared statement - and decode them to
JS values. The row count is itself a real bind parameter ($1), not a
literal, and large enough that column-decode work dominates the
measurement rather than per-call round-trip overhead.
This is the Extended Query counterpart to Simple Query Fetch above: the
raw decode cost this protocol carries per call, before Prepared Statement
Reuse below measures what reusing the parsed plan saves.
Excludes int8: pg, postgres.js and PostgreJS return it as genuinely
different JS types by default (string, BigInt, number-or-BigInt). Timing
that column would measure type-conversion choice, not decode speed.
Forces PostgreJS onto the text protocol explicitly. Its Extended Query
default is binary, per-column, unlike pg and postgres.js, which are always
text here - pg's binary mode is opt-in and never requested, and
postgres.js has no binary protocol support at all. Without that, this
scenario would compare binary decode against text decode, not decode
speed. (rowTarget=1000)
| Library | Mean (ms) | p75 (ms) | p99 (ms) | ops/sec | vs. slowest | GC (ms/op) | Peak Heap (KB) | Retained (KB) |
|---|---:|---:|---:|---:|---:|---:|---:|---:|
| PostgreJS (3.12.0) | 1.426 | 1.636 | 2.534 | 728.9 | 1.14x | — | 22402.66 | 2786.89 |
| pg (node-postgres) (8.23.0) | 1.626 | 1.888 | 2.754 | 641.7 | 1.00x | — | 18211.95 | 1735.31 |
| postgres (postgres.js) (3.4.9) | 1.430 | 1.691 | 2.639 | 740.8 | 1.14x | — | 15992.59 | 1943.86 |
| Bun.sql (1.4.2) | ***0.847*** | ***0.880*** | ***1.612*** | ***1239.7*** | ***1.92x*** | — | ***11179.35*** | ***1135.51*** |
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Mean latency (ms, lower is better)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "ms" 0.0000 --> 2.4396
bar [1.4261, 1.6264, 1.4296, 0.8468]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}, 'themeVariables': {'xyChart': {'plotColorPalette': '#f2a900'}}}}%%
xychart-beta
title "Throughput (ops/sec, higher is better)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "ops/sec" 0.0000 --> 1859.5890
bar [728.8876, 641.6758, 740.7606, 1239.7260]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Peak heap growth (KB, max memory reached)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "KB" 0.0000 --> 33603.9917
bar [22402.6611, 18211.9453, 15992.5928, 11179.3496]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Retained heap (KB, still held after the run)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "KB" 0.0000 --> 4180.3389
bar [2786.8926, 1735.3145, 1943.8574, 1135.5137]
```
### Mixed-Type Decode (Binary Protocol)
The same fetch as Mixed-Type Decode (Text Protocol) above - same
1000 rows, same columns, same bind-parameter
row count - but requesting binary result format instead of text. That is
PostgreJS's own Extended Query default (`DEFAULT_COLUMN_FORMAT`), so this
measures its binary decode path on its own terms rather than forcing it
onto text.
postgres.js has no binary protocol support at all: its `Bind` message
hardcodes text format codes for every column, with no option to request
binary (verified in its own source). It isn't benchmarked here.
pg's binary parser table (`pg-types`) is missing exactly the column types
this scenario decodes - `varchar`/`json`/`jsonb`/`bytea` are unregistered
for binary, only a handful of numeric/date/bool types are. Requesting
binary from pg would return those columns unparsed or corrupted rather
than a comparable value, so it's excluded rather than reported as a
misleading number.
Bun's SQL client already uses binary for several of these columns by
default - int4, float4, float8, timestamp, timestamptz, and bytea, verified
by capturing its actual `Bind` message over a logging TCP proxy - but int2,
int8, varchar, json, and jsonb go out as text regardless, a fixed per-type
choice with no exposed option (in the SQL constructor, `.unsafe()`, or the
tagged-template call) to override it either way. Since it can't be forced
into PostgreJS's "request binary for every column" shape, its result here
would be neither this scenario nor a fair text-protocol one - it isn't
benchmarked here for that reason.
Only PostgreJS's own result is shown. (rowTarget=1000)
| Library | Mean (ms) | p75 (ms) | p99 (ms) | ops/sec | vs. slowest | GC (ms/op) | Peak Heap (KB) | Retained (KB) |
|---|---:|---:|---:|---:|---:|---:|---:|---:|
| PostgreJS (3.12.0) | 1.303 | 1.493 | 2.190 | 796.2 | 1.00x | — | 23823.39 | 2971.13 |
| pg (node-postgres) | Not Fully Supported | — | — | — | — | — | — | — |
| postgres (postgres.js) | Not Supported | — | — | — | — | — | — | — |
| Bun.sql | Not Controllable | — | — | — | — | — | — | — |
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Mean latency (ms, lower is better)"
x-axis ["PostgreJS"]
y-axis "ms" 0.0000 --> 1.9550
bar [1.3033]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}, 'themeVariables': {'xyChart': {'plotColorPalette': '#f2a900'}}}}%%
xychart-beta
title "Throughput (ops/sec, higher is better)"
x-axis ["PostgreJS"]
y-axis "ops/sec" 0.0000 --> 1194.2840
bar [796.1893]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Peak heap growth (KB, max memory reached)"
x-axis ["PostgreJS"]
y-axis "KB" 0.0000 --> 35735.0801
bar [23823.3867]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Retained heap (KB, still held after the run)"
x-axis ["PostgreJS"]
y-axis "KB" 0.0000 --> 4456.6934
bar [2971.1289]
```
### Large Blob Fetch
Fetch 10 rows of a
1MB bytea value each
(10MB total)
via each library's Extended Query path, with the row count itself a real
bind parameter, not a literal. The measurement is dominated by
wire-transfer and decode time for a few large values, instead of
per-row/per-column overhead across many small ones - the counterpart to
Mixed-Type Decode above, which is many small values.
Unlike that scenario, no protocol format is forced onto anyone here:
PostgreJS is left on its own Extended Query default (binary), and
pg/postgres.js get whatever their own default is.
postgres.js has no binary protocol support at all (verified elsewhere in
this report), so it always fetches as text - hex-encoded on the wire,
decoded client-side. pg's binary parser table (`pg-types`) has no entry
for `bytea` either (verified live: requesting binary format for a bytea
column returns a corrupted value, not a Buffer) - undocumented and unsafe
to rely on, so pg is left on its own text default too, same as
postgres.js.
Only PostgreJS ends up genuinely exercising a binary fetch; the other two
show their real, best-available path rather than a forced or broken one -
and pay for it. bytea's text format is `\x`-prefixed hex, literally 2x the
wire bytes of binary's raw bytes, so pg and postgres.js transfer twice
what PostgreJS does here. (sizeBytes=1048576, rowCount=10)
| Library | Mean (ms) | p75 (ms) | p99 (ms) | ops/sec | vs. slowest | GC (ms/op) | Peak Heap (KB) | Retained (KB) | Net in (KB/op) | Net out (KB/op) |
|---|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|
| PostgreJS (3.12.0) | 31.243 | 31.421 | 34.089 | 32.0 | 1.98x | — | 105978.56 | 22303.19 | ***12412.27*** | ***0.06*** |
| pg (node-postgres) (8.23.0) | 61.815 | 62.633 | 64.233 | 16.2 | 1.00x | — | 134113.37 | 21483.21 | 25600.23 | 0.13 |
| postgres (postgres.js) (3.4.9) | 60.277 | 60.817 | 63.575 | 16.6 | 1.03x | — | 143654.00 | 25243.59 | 25600.19 | 0.06 |
| Bun.sql (1.4.2) | ***29.844*** | ***30.177*** | ***31.360*** | ***33.5*** | ***2.07x*** | — | ***78081.55*** | ***20992.81*** | — | — |
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Mean latency (ms, lower is better)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "ms" 0.0000 --> 92.7230
bar [31.2431, 61.8153, 60.2771, 29.8441]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}, 'themeVariables': {'xyChart': {'plotColorPalette': '#f2a900'}}}}%%
xychart-beta
title "Throughput (ops/sec, higher is better)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "ops/sec" 0.0000 --> 50.3056
bar [32.0375, 16.1813, 16.5994, 33.5371]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Peak heap growth (KB, max memory reached)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "KB" 0.0000 --> 215481.0000
bar [105978.5645, 134113.3691, 143654.0000, 78081.5527]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Retained heap (KB, still held after the run)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "KB" 0.0000 --> 37865.3848
bar [22303.1934, 21483.2051, 25243.5898, 20992.8066]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Network received (KB/op, lower is better)"
x-axis ["PostgreJS", "pg", "postgres"]
y-axis "KB/op" 0.0000 --> 38400.3497
bar [12412.2729, 25600.2332, 25600.1927]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Network sent (KB/op, lower is better)"
x-axis ["PostgreJS", "pg", "postgres"]
y-axis "KB/op" 0.0000 --> 0.1978
bar [0.0555, 0.1318, 0.0612]
```
### Large Array Fetch
Fetch 10 rows of an int4[] with
50000 elements each, via each library's Extended
Query path, with the row count itself a real bind parameter, not a
literal. Elements alternate between just below int4's ceiling and just
above its floor, so every value is full-width and roughly half are
negative. Full-width values are what show binary format's real wire
advantage: binary spends a fixed 8 bytes per int4 element, while text
spends one byte per digit.
This is the array counterpart to Large Blob Fetch above (one large scalar
value) and Mixed-Type Decode (many small values): here it is many elements
within a single column value, repeated across rows. Element count, not
byte size, is what drives cost for an array, unlike a blob - see this
file's own comments for the measurement that showed why - so this is
sized for a clear decode-time gap without ballooning each iteration to
whole seconds.
As with Large Blob Fetch, no protocol format is forced onto anyone:
PostgreJS is left on its own Extended Query default (binary).
pg's binary array decode (`pg-types`) is registered-but-buggy rather than
simply unsupported. It does have a registered binary parser for `_int4`
(unlike `bytea`), but that parser reads every element as an unsigned bit
pattern, with no two's-complement handling for negative values. Verified
live: requesting binary format for an int4[] containing negative numbers
returns wrong values from the first negative element onward, and desyncs
the element count entirely on a larger array - a 1500-element array came
back as 1519 elements, values wrong.
So pg is left on its own text default here too, same as postgres.js (no
binary protocol support at all, verified elsewhere in this report). A case
where a library merely having a registered binary parser is not the same
as that parser being safe to use. (elementCount=50000, rowCount=10)
| Library | Mean (ms) | p75 (ms) | p99 (ms) | ops/sec | vs. slowest | GC (ms/op) | Peak Heap (KB) | Retained (KB) | Net in (KB/op) | Net out (KB/op) |
|---|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|
| PostgreJS (3.12.0) | ***14.087*** | ***14.244*** | ***16.501*** | ***71.3*** | ***3.48x*** | — | 34369.70 | 5831.70 | ***4676.88*** | ***0.05*** |
| pg (node-postgres) (8.23.0) | 49.065 | 49.847 | 51.072 | 20.4 | 1.00x | — | 55497.04 | ***1931.03*** | 6952.41 | 0.13 |
| postgres (postgres.js) (3.4.9) | 27.251 | 27.373 | 30.440 | 36.8 | 1.80x | — | 42695.83 | 6729.83 | 6677.75 | 0.06 |
| Bun.sql (1.4.2) | 17.524 | 18.225 | 23.579 | 57.7 | 2.80x | — | ***23111.20*** | 4489.32 | — | — |
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Mean latency (ms, lower is better)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "ms" 0.0000 --> 73.5978
bar [14.0875, 49.0652, 27.2512, 17.5240]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}, 'themeVariables': {'xyChart': {'plotColorPalette': '#f2a900'}}}}%%
xychart-beta
title "Throughput (ops/sec, higher is better)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "ops/sec" 0.0000 --> 106.9153
bar [71.2769, 20.3895, 36.7545, 57.7181]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Peak heap growth (KB, max memory reached)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "KB" 0.0000 --> 83245.5645
bar [34369.6953, 55497.0430, 42695.8301, 23111.2012]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Retained heap (KB, still held after the run)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "KB" 0.0000 --> 10094.7451
bar [5831.7012, 1931.0332, 6729.8301, 4489.3164]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Network received (KB/op, lower is better)"
x-axis ["PostgreJS", "pg", "postgres"]
y-axis "KB/op" 0.0000 --> 10428.6207
bar [4676.8788, 6952.4138, 6677.7468]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Network sent (KB/op, lower is better)"
x-axis ["PostgreJS", "pg", "postgres"]
y-axis "KB/op" 0.0000 --> 0.1977
bar [0.0524, 0.1318, 0.0561]
```
### Prepared Statement Reuse (Sequential)
Prepare once and execute 50 times,
one at a time, each awaited before the next starts. Each library uses its
own prepared-statement mechanism: postgres.js auto-prepares, pg uses a
named statement, PostgreJS uses explicit prepare()/execute()/close().
Compare it against the Concurrent variant below to see what overlapping
executions of the same reused statement buys each library.
Excludes int8: pg, postgres.js and PostgreJS return it as genuinely
different JS types by default (string, BigInt, number-or-BigInt), so
timing it would measure type-conversion choice, not reuse cost. (iterations=50)
| Library | Mean (ms) | p75 (ms) | p99 (ms) | ops/sec | vs. slowest | GC (ms/op) | Peak Heap (KB) | Retained (KB) |
|---|---:|---:|---:|---:|---:|---:|---:|---:|
| PostgreJS (3.12.0) | 10.064 | ***10.020*** | 12.028 | 100.5 | 1.00x | — | 9042.78 | 2336.78 |
| pg (node-postgres) (8.23.0) | 9.994 | ***10.021*** | 12.955 | 100.5 | 1.01x | — | 17310.02 | 1789.82 |
| postgres (postgres.js) (3.4.9) | 10.045 | ***10.119*** | 11.836 | 100.2 | 1.00x | — | 18010.30 | 1284.21 |
| Bun.sql (1.4.2) | ***9.542*** | ***9.673*** | ***11.078*** | ***104.9*** | ***1.05x*** | — | ***1142.17*** | ***729.66*** |
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Mean latency (ms, lower is better)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "ms" 0.0000 --> 15.0961
bar [10.0640, 9.9944, 10.0446, 9.5418]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}, 'themeVariables': {'xyChart': {'plotColorPalette': '#f2a900'}}}}%%
xychart-beta
title "Throughput (ops/sec, higher is better)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "ops/sec" 0.0000 --> 157.4023
bar [100.5410, 100.5403, 100.1605, 104.9349]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Peak heap growth (KB, max memory reached)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "KB" 0.0000 --> 27015.4512
bar [9042.7793, 17310.0156, 18010.3008, 1142.1699]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Retained heap (KB, still held after the run)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "KB" 0.0000 --> 3505.1660
bar [2336.7773, 1789.8242, 1284.2148, 729.6602]
```
### Prepared Statement Reuse (Concurrent)
The concurrent counterpart to Sequential above: prepare once,
then fire 50 executions of
that same reused statement on the SAME already-open connection without
awaiting each one individually, then await them all via Promise.all().
Each library uses its own prepared-statement mechanism: postgres.js
auto-prepares, pg uses a named statement, PostgreJS uses explicit
prepare()/execute()/close().
Excludes int8: pg, postgres.js and PostgreJS return it as genuinely
different JS types by default (string, BigInt, number-or-BigInt), so
timing it would measure type-conversion choice, not reuse cost. (concurrency=50)
| Library | Mean (ms) | p75 (ms) | p99 (ms) | ops/sec | vs. slowest | GC (ms/op) | Peak Heap (KB) | Retained (KB) |
|---|---:|---:|---:|---:|---:|---:|---:|---:|
| PostgreJS (3.12.0) | ***0.980*** | 1.020 | ***1.503*** | ***1035.9*** | ***1.11x*** | — | 22501.46 | 2496.37 |
| pg (node-postgres) (8.23.0) | 1.073 | 1.130 | 1.790 | 952.3 | 1.01x | — | 19469.99 | 1958.93 |
| postgres (postgres.js) (3.4.9) | ***0.935*** | ***0.970*** | ***1.457*** | ***1085.6*** | ***1.16x*** | — | 17910.38 | 1470.72 |
| Bun.sql (1.4.2) | 1.085 | 1.121 | 1.924 | 938.3 | 1.00x | — | ***10902.18*** | ***858.44*** |
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Mean latency (ms, lower is better)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "ms" 0.0000 --> 1.6281
bar [0.9799, 1.0726, 0.9349, 1.0854]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}, 'themeVariables': {'xyChart': {'plotColorPalette': '#f2a900'}}}}%%
xychart-beta
title "Throughput (ops/sec, higher is better)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "ops/sec" 0.0000 --> 1628.3737
bar [1035.8791, 952.3333, 1085.5825, 938.3394]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Peak heap growth (KB, max memory reached)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "KB" 0.0000 --> 33752.1855
bar [22501.4570, 19469.9893, 17910.3770, 10902.1797]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Retained heap (KB, still held after the run)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "KB" 0.0000 --> 3744.5479
bar [2496.3652, 1958.9297, 1470.7227, 858.4375]
```
## Unit of Work
Several different statements run as one unit, the shape a single request usually has - a few writes, a few reads, none of them repeating. Every library sends them without waiting between replies, which all three can do; what separates them is whether each statement still costs its own `Sync`, and with it a round of the server's implicit-transaction bookkeeping. Distinct from the Concurrent Execution scenarios above, where the same query is fired many times and a parsed plan can be shared.
### Unit of Work
Runs 20 different statements - ten writes, five
reads, then five more writes - as one unit, the shape a single request
usually has. Unlike the Concurrent Execution scenarios, which fire the same
query many times, every statement here is different, so none of them can
share a parsed plan with another.
Each library uses the fastest path it has for this. pg and postgres.js fire
the statements through `Promise.all()` without awaiting between them, which
is genuinely their best: both pipeline, so the statements travel without
waiting for each other's replies. postgres.js builds them from its tagged
template rather than `sql.unsafe()` - on this workload that is 3.5x faster
for it (4.4ms against 15.5ms), so the `$1` form would have measured a path
its users have no reason to take. PostgreJS uses `pipeline()`, which goes
one step further and closes all twenty with a single `Sync` instead of one
each.
That last step is what the scenario is really measuring, and it is not a
configuration difference: a `Sync` per statement makes the server finish an
implicit transaction and answer ReadyForQuery every time, and neither other
driver can avoid it - pg sends one immediately after each Execute, and
postgres.js concatenates Execute and Sync into a single constant, so the
two cannot come apart. Compare against Concurrent Execution (Extended
Query) above to see the same libraries running the same number of calls
when the statements are identical rather than different. (statementCount=20)
| Library | Mean (ms) | p75 (ms) | p99 (ms) | ops/sec | vs. slowest | GC (ms/op) | Peak Heap (KB) | Retained (KB) |
|---|---:|---:|---:|---:|---:|---:|---:|---:|
| PostgreJS (3.12.0) | ***0.596*** | ***0.601*** | ***0.891*** | ***1695.2*** | ***4.42x*** | — | ***6474.69*** | 2145.87 |
| pg (node-postgres) (8.23.0) | 2.632 | 2.689 | 3.207 | 381.5 | 1.00x | — | 16210.84 | 1723.63 |
| postgres (postgres.js) (3.4.9) | 2.031 | 2.075 | 2.775 | 495.2 | 1.30x | — | 17196.25 | 1337.28 |
| Bun.sql (1.4.2) | 2.336 | 2.394 | 3.206 | 431.0 | 1.13x | — | 10724.86 | ***781.33*** |
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Mean latency (ms, lower is better)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "ms" 0.0000 --> 3.9486
bar [0.5960, 2.6324, 2.0315, 2.3361]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}, 'themeVariables': {'xyChart': {'plotColorPalette': '#f2a900'}}}}%%
xychart-beta
title "Throughput (ops/sec, higher is better)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "ops/sec" 0.0000 --> 2542.8017
bar [1695.2011, 381.4774, 495.2471, 430.9543]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Peak heap growth (KB, max memory reached)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "KB" 0.0000 --> 25794.3779
bar [6474.6875, 16210.8379, 17196.2520, 10724.8633]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Retained heap (KB, still held after the run)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "KB" 0.0000 --> 3218.8096
bar [2145.8730, 1723.6250, 1337.2773, 781.3340]
```
## Bulk Load
`COPY ... FROM STDIN`, the path PostgreSQL optimises for writing many rows at once - one statement carrying a stream of rows instead of an INSERT per row or a bind per row. The two scenarios are the same 200,000 rows sent two ways: as CSV every library formats itself, and as the binary COPY format only PostgreJS can produce. Read them together - the text table is what separates the drivers, and the difference between the tables is what the format buys. Both scenarios truncate the destination inside the timed call and start from the same materialised rows, so each library pays for its own formatting rather than being handed a payload someone else built.
### Bulk Load (text COPY)
Bulk-loads 200,000 rows into an empty table over
`COPY ... FROM STDIN`, the path PostgreSQL itself optimises for bulk
writes. Each iteration truncates the destination first, so every run loads
into the same empty table - the truncate is inside the timed call and
costs every library the same.
Column values hug each type's widest text form, the same choice the seeded
tables make: binary costs a fixed number of bytes per column whatever the
value is, while text costs one per character, so a payload of small numbers
would understate the format difference and unusually long ones would
overstate it.
That choice moves the headline enough to state outright. On these same
200,000 rows, text against binary: with these values (10-digit int4,
19-digit int8, widest float8, 40-char varchar) 2495ms against 242ms, a
10.3x gap over ~22MB of CSV; with single-digit numbers and 4-char strings
instead, 497ms against 187ms, a 2.7x gap over ~8MB. Both are honest for
their own data and neither is universal - binary's cost per column doesn't
move between those runs, what changes is how much text the server has to
parse. Place the table against your own rows rather than reading one figure
as the answer.
This is the like-for-like comparison: every library formats the same CSV
payload and streams it as bytes, which is the only thing pg and
postgres.js can do (see Bulk Load (binary COPY) below). PostgreJS uses its
own `copyFrom()` byte stream here rather than `copyFromRows()`, so what
is measured is the driver's COPY transport, not the format.
pg needs `pg-copy-streams` for this at all - its core `Query` refuses
COPY IN - which is installed here so it runs its real path rather than
being marked unsupported. (rowCount=200000)
| Library | Mean (ms) | p75 (ms) | p99 (ms) | ops/sec | vs. slowest | GC (ms/op) | Peak Heap (KB) | Retained (KB) | Net in (KB/op) | Net out (KB/op) |
|---|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|
| PostgreJS (3.12.0) | ***1442.235*** | ***1438.335*** | ***1470.249*** | ***0.7*** | ***1.00x*** | — | 231881.03 | 705.89 | ***0.09*** | ***32387.29*** |
| pg (node-postgres) (8.23.0) | ***1445.071*** | ***1444.694*** | ***1463.134*** | ***0.7*** | ***1.00x*** | — | ***185564.74*** | 653.72 | 0.18 | ***32387.36*** |
| postgres (postgres.js) (3.4.9) | ***1444.324*** | ***1451.974*** | ***1464.001*** | ***0.7*** | ***1.00x*** | — | 231710.53 | ***528.23*** | 0.18 | ***32387.38*** |
| Bun.sql | No COPY API | — | — | — | — | — | — | — | — | — |
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Mean latency (ms, lower is better)"
x-axis ["PostgreJS", "pg", "postgres"]
y-axis "ms" 0.0000 --> 2167.6062
bar [1442.2353, 1445.0708, 1444.3235]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}, 'themeVariables': {'xyChart': {'plotColorPalette': '#f2a900'}}}}%%
xychart-beta
title "Throughput (ops/sec, higher is better)"
x-axis ["PostgreJS", "pg", "postgres"]
y-axis "ops/sec" 0.0000 --> 1.0401
bar [0.6934, 0.6920, 0.6924]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Peak heap growth (KB, max memory reached)"
x-axis ["PostgreJS", "pg", "postgres"]
y-axis "KB" 0.0000 --> 347821.5381
bar [231881.0254, 185564.7402, 231710.5273]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Retained heap (KB, still held after the run)"
x-axis ["PostgreJS", "pg", "postgres"]
y-axis "KB" 0.0000 --> 1058.8330
bar [705.8887, 653.7207, 528.2305]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Network received (KB/op, lower is better)"
x-axis ["PostgreJS", "pg", "postgres"]
y-axis "KB/op" 0.0000 --> 0.2687
bar [0.0916, 0.1791, 0.1791]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Network sent (KB/op, lower is better)"
x-axis ["PostgreJS", "pg", "postgres"]
y-axis "KB/op" 0.0000 --> 48581.0678
bar [32387.2896, 32387.3648, 32387.3785]
```
### Bulk Load (binary COPY)
Bulk-loads 200,000 rows into an empty table over
`COPY ... FROM STDIN`, the path PostgreSQL itself optimises for bulk
writes. Each iteration truncates the destination first, so every run loads
into the same empty table - the truncate is inside the timed call and
costs every library the same.
Column values hug each type's widest text form, the same choice the seeded
tables make: binary costs a fixed number of bytes per column whatever the
value is, while text costs one per character, so a payload of small numbers
would understate the format difference and unusually long ones would
overstate it.
That choice moves the headline enough to state outright. On these same
200,000 rows, text against binary: with these values (10-digit int4,
19-digit int8, widest float8, 40-char varchar) 2495ms against 242ms, a
10.3x gap over ~22MB of CSV; with single-digit numbers and 4-char strings
instead, 497ms against 187ms, a 2.7x gap over ~8MB. Both are honest for
their own data and neither is universal - binary's cost per column doesn't
move between those runs, what changes is how much text the server has to
parse. Place the table against your own rows rather than reading one figure
as the answer.
The same rows as Bulk Load (text COPY) above, loaded through PostgreJS's
`copyFromRows()`, which encodes them into PostgreSQL's binary COPY format
instead of CSV. Read the two tables together: the difference between them
is what the format buys, while the text table alone is what separates the
drivers.
pg and postgres.js are absent because neither can produce the format.
Both can carry a binary COPY payload the caller has already encoded - so
this is not a missing transport - but producing it needs a binary encoder
per type, which neither has. For pg a third-party package,
`pg-copy-streams-binary`, supplies its own encoders; it is left out here
for the same reason `pg-native` is, being outside the driver rather than
part of it. (rowCount=200000)
| Library | Mean (ms) | p75 (ms) | p99 (ms) | ops/sec | vs. slowest | GC (ms/op) | Peak Heap (KB) | Retained (KB) | Net in (KB/op) | Net out (KB/op) |
|---|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|
| PostgreJS (3.12.0) | 89.350 | 89.965 | 133.661 | 11.4 | 1.00x | — | 18574.44 | 18440.72 | 0.28 | 21289.32 |
| pg (node-postgres) | No binary COPY encoding | — | — | — | — | — | — | — | — | — |
| postgres (postgres.js) | No binary COPY encoding | — | — | — | — | — | — | — | — | — |
| Bun.sql | No COPY API | — | — | — | — | — | — | — | — | — |
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Mean latency (ms, lower is better)"
x-axis ["PostgreJS"]
y-axis "ms" 0.0000 --> 134.0243
bar [89.3495]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}, 'themeVariables': {'xyChart': {'plotColorPalette': '#f2a900'}}}}%%
xychart-beta
title "Throughput (ops/sec, higher is better)"
x-axis ["PostgreJS"]
y-axis "ops/sec" 0.0000 --> 17.0848
bar [11.3899]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Peak heap growth (KB, max memory reached)"
x-axis ["PostgreJS"]
y-axis "KB" 0.0000 --> 27861.6563
bar [18574.4375]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Retained heap (KB, still held after the run)"
x-axis ["PostgreJS"]
y-axis "KB" 0.0000 --> 27661.0781
bar [18440.7188]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Network received (KB/op, lower is better)"
x-axis ["PostgreJS"]
y-axis "KB/op" 0.0000 --> 0.4230
bar [0.2820]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Network sent (KB/op, lower is better)"
x-axis ["PostgreJS"]
y-axis "KB/op" 0.0000 --> 31933.9758
bar [21289.3172]
```
## Cursor Streaming
A server-side cursor (postgrejs's `Connection.query(sql, { cursor: true })`) fetches rows in bounded batches via repeated Extended Query `Execute` calls against a portal, instead of the server materializing and sending the whole result set at once. The relevant metric when a result set doesn't comfortably fit in memory, not raw single-shot throughput.
### Cursor Streaming
Stream 50000 rows via a server-side cursor in batches of 500.
Excludes int8: pg/postgres.js/PostgreJS return it as genuinely different JS types by default (string/BigInt/number-or-BigInt),
so timing it would measure type-conversion choice, not streaming throughput.
Bun's SQL client has no cursor/streaming API at all - no `.cursor()`, no
`.forEach()`, no `Symbol.asyncIterator` on a query (verified against its
own type declarations and empirically). It isn't benchmarked here. (rowTarget=50000, batchSize=500)
| Library | Mean (ms) | p75 (ms) | p99 (ms) | ops/sec | vs. slowest | GC (ms/op) | Peak Heap (KB) | Retained (KB) |
|---|---:|---:|---:|---:|---:|---:|---:|---:|
| PostgreJS (3.12.0) | ***84.376*** | ***84.993*** | ***87.497*** | ***11.9*** | ***1.29x*** | — | 26515.09 | 2471.81 |
| pg (node-postgres) (8.23.0) | 109.013 | 108.802 | 131.011 | 9.3 | 1.00x | — | 17647.19 | 1300.50 |
| postgres (postgres.js) (3.4.9) | ***84.587*** | ***84.937*** | ***91.432*** | ***11.8*** | ***1.29x*** | — | ***16377.09*** | ***891.98*** |
| Bun.sql | Not Supported | — | — | — | — | — | — | — |
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Mean latency (ms, lower is better)"
x-axis ["PostgreJS", "pg", "postgres"]
y-axis "ms" 0.0000 --> 163.5193
bar [84.3757, 109.0129, 84.5872]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}, 'themeVariables': {'xyChart': {'plotColorPalette': '#f2a900'}}}}%%
xychart-beta
title "Throughput (ops/sec, higher is better)"
x-axis ["PostgreJS", "pg", "postgres"]
y-axis "ops/sec" 0.0000 --> 17.7855
bar [11.8570, 9.2521, 11.8350]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Peak heap growth (KB, max memory reached)"
x-axis ["PostgreJS", "pg", "postgres"]
y-axis "KB" 0.0000 --> 39772.6348
bar [26515.0898, 17647.1934, 16377.0859]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Retained heap (KB, still held after the run)"
x-axis ["PostgreJS", "pg", "postgres"]
y-axis "KB" 0.0000 --> 3707.7158
bar [2471.8105, 1300.5000, 891.9824]
```
## Connection Pooling
The overhead each library's connection pool adds on top of the raw per-query costs measured above: running many queries concurrently through a shared pool (postgrejs's `Pool.query()`), and isolating the pure cost of acquiring and releasing a pooled connection from the cost of the query itself.
### Pooled Simple Query
Same query as Sequential Execution/Concurrent Execution above,
run through a pool instead of a single open connection:
1000 concurrent `select 1 as one`
queries against a pool of max size 10,
using each library's own top-level pooled entry point. (concurrency=1000, poolSize=10)
| Library | Mean (ms) | p75 (ms) | p99 (ms) | ops/sec | vs. slowest | GC (ms/op) | Peak Heap (KB) | Retained (KB) |
|---|---:|---:|---:|---:|---:|---:|---:|---:|
| PostgreJS (3.12.0) | ***6.734*** | ***7.158*** | ***9.724*** | ***152.4*** | ***6.35x*** | — | 23454.28 | 4011.17 |
| pg (node-postgres) (8.23.0) | 42.515 | 42.448 | 48.622 | 23.6 | 1.01x | — | 17396.51 | 2775.22 |
| postgres (postgres.js) (3.4.9) | 7.926 | 9.835 | 13.128 | 141.6 | 5.40x | — | 24326.35 | 3821.04 |
| Bun.sql (1.4.2) | 42.777 | 43.072 | 49.099 | 23.4 | 1.00x | — | ***10283.34*** | ***1314.56*** |
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Mean latency (ms, lower is better)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "ms" 0.0000 --> 64.1658
bar [6.7343, 42.5152, 7.9260, 42.7772]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}, 'themeVariables': {'xyChart': {'plotColorPalette': '#f2a900'}}}}%%
xychart-beta
title "Throughput (ops/sec, higher is better)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "ops/sec" 0.0000 --> 228.5595
bar [152.3730, 23.5769, 141.6428, 23.4190]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Peak heap growth (KB, max memory reached)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "KB" 0.0000 --> 36489.5244
bar [23454.2793, 17396.5137, 24326.3496, 10283.3398]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Retained heap (KB, still held after the run)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "KB" 0.0000 --> 6016.7607
bar [4011.1738, 2775.2207, 3821.0352, 1314.5645]
```
### Pooled Extended Query
The Extended Query counterpart to Pooled Simple Query above: the
same 1000 concurrent calls against a
pool of max size 10, but binding a
real query parameter (`select $1::int4 as one`) so every library goes
through Parse/Bind/Describe/Execute/Sync instead of a single Query
message.
Each call is a one-shot statement, not a reused prepared one, so this
shows what a pool costs on top of the per-call Extended Query overhead.
Compare it against this group's Pooled Simple Query to see what the extra
protocol round of messages adds once connections are being shared.
Read the margin here with that one-shot constraint in mind. postgres.js's
unprepared path (`sql.unsafe(query, args)`, the same call the
single-connection Sequential Execution scenario uses, where it comes out
ahead) does not pipeline a burst the way its prepared path does. Letting
it cache the statement instead turns this into a different measurement
entirely, which is what Prepared Statement Reuse below covers. (concurrency=1000, poolSize=10)
| Library | Mean (ms) | p75 (ms) | p99 (ms) | ops/sec | vs. slowest | GC (ms/op) | Peak Heap (KB) | Retained (KB) |
|---|---:|---:|---:|---:|---:|---:|---:|---:|
| PostgreJS (3.12.0) | 6.628 | 7.243 | 9.001 | 156.7 | 6.78x | — | 29702.15 | 5014.79 |
| pg (node-postgres) (8.23.0) | 44.950 | 46.780 | 52.166 | 22.4 | 1.00x | — | 21098.95 | 3120.01 |
| postgres (postgres.js) (3.4.9) | 7.648 | 9.995 | 13.469 | 155.7 | 5.88x | — | 22333.50 | 3952.87 |
| Bun.sql (1.4.2) | ***3.615*** | ***3.855*** | ***4.829*** | ***282.2*** | ***12.44x*** | — | ***12023.35*** | ***1327.41*** |
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Mean latency (ms, lower is better)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "ms" 0.0000 --> 67.4255
bar [6.6279, 44.9503, 7.6480, 3.6147]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}, 'themeVariables': {'xyChart': {'plotColorPalette': '#f2a900'}}}}%%
xychart-beta
title "Throughput (ops/sec, higher is better)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "ops/sec" 0.0000 --> 423.2898
bar [156.6515, 22.3864, 155.6796, 282.1932]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Peak heap growth (KB, max memory reached)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "KB" 0.0000 --> 44553.2256
bar [29702.1504, 21098.9473, 22333.5000, 12023.3457]
```
```mermaid
%%{init: {'xyChart': {'width': 600, 'height': 300, 'chartOrientation': 'horizontal'}}}%%
xychart-beta
title "Retained heap (KB, still held after the run)"
x-axis ["PostgreJS", "pg", "postgres", "Bun.sql"]
y-axis "KB" 0.0000 --> 7522.1924
bar [5014.7949, 3120.0117, 3952.8672, 1327.4063]
```
## Raw data
Backing raw data for the numbers above lives in `benchmark/results/bun/*.json` (gitignored; regenerate with `npm run bench:bun`).