50 Million Query Throughput (Zig)
Prepared statements, pipeline mode, and 10,000 queries per batch.
| Driver | Protocol | Queries/s | Relative to Rust baseline |
|---|---|---|---|
| Rust qail-pg | Native Tokio | 331,885 | 100% |
| Zig (prepared) | Native std.net | 315,708 | 95% |
| Zig (simple query) | Simple Query protocol | 92,000 | 28% |
Prepared-path note
The prepared Zig path recorded 315,708 q/s against 331,885 q/s for the Rust baseline in this dated run. Read it as a historical measurement of one runtime split rather than the current canonical Zig benchmark surface.
Historical pg.zig comparison setup
- pg.zig uses the Extended Query protocol and parses typed responses.
- qail-zig initially omitted response parsing, so the comparison was rerun after adding a parsing interface.
- The harness below keeps both paths at the same 55,000 parsed rows.
Historical pg.zig Comparison
| Driver | Work done | Queries/s | Rows parsed |
|---|---|---|---|
| qail-zig | Zig I/O plus Rust FFI, response parse | 33,866 | 55,000 |
| pg.zig | Pure Zig, response parse | 16,990 | 55,000 |
Response parsing interface added for this benchmark
qail_decode_response(bytes)returns a response handle.qail_response_row_count(handle)reports parsed rows.qail_response_get_i32(handle, row, col)andqail_response_get_string(handle, row, col)expose values.- A dynamic library build was used for the recorded run after the static build triggered linker faults in the harness.
Observed single-query ratio
The rerun recorded 33,866 q/s versus 16,990 q/s with matched 55,000-row parsing. That ratio belongs to the single-query harness documented here, not to the separate prepared pipeline numbers above.
Key findings
- Prepared statements mattered materially in the dated run: 315,708 q/s versus 92,000 q/s for the simple path.
- Wire bytes were lower on the prepared path than on the simple-query path.
- FFI call volume was not the primary bottleneck relative to network and protocol work.
- The hot path stayed allocation-light on both the Rust and Zig sides.
Architecture
qail-zig (native Zig I/O)
- std.net TCP connect
- stream.write(bytes)
- stream.read(response)
qail-encoder (Rust FFI)
- qail_encode_parse()
- qail_encode_bind_execute_batch()
- qail_encode_sync()
PostgreSQL wire protocol FAQ
What does this report optimize for?
It measures PostgreSQL wire-protocol throughput under prepared statements, batching, and response parsing behavior for the historical qail-zig runtime split.
How should I use it for PostgreSQL Zig decisions?
Treat it as comparative signal, then rerun on your own workload. Use /zig for current setup details and /zig/docs/benchmarks.html for the current public Zig benchmark report.
Is pg.zig included in a matched single-query comparison?
Yes. The historical section includes a matched single-query comparison where both paths parse responses.