Home Expressions
Docs
Drivers Gateway SDKs Benchmarks
Changelog
GitHub
Blog Status Roadmap
← Back to benchmark index
Historical Zig page December 27, 2025

PostgreSQL Zig Report: 50 Million Query Snapshot

Historical benchmark page for PostgreSQL Zig driver throughput and the older pg.zig comparison.

This page supports readers evaluating PostgreSQL Zig driver performance. For install and runtime details, pair it with /zig and /drivers.
95%

prepared-path throughput relative to the Rust baseline in this run

315,708
Zig queries/s
prepared path
331,885
Rust queries/s
workspace baseline
50M
Total queries
pipeline benchmark

50 Million Query Throughput (Zig)

Prepared statements, pipeline mode, and 10,000 queries per batch.

DriverProtocolQueries/sRelative to Rust baseline
Rust qail-pgNative Tokio331,885100%
Zig (prepared)Native std.net315,70895%
Zig (simple query)Simple Query protocol92,00028%

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

DriverWork doneQueries/sRows parsed
qail-zigZig I/O plus Rust FFI, response parse33,86655,000
pg.zigPure Zig, response parse16,99055,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) and qail_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.