HomePlaygroundExpressionsDocsDriversStatusChangelog GitHub

🐘 PHP Extension (Single Query - Fair Comparison)

Native C extension wrapping Rust β€’ Same query pattern as Eloquent (no batching)

Driver Implementation Queries/Second vs Eloquent
qail-php (Single) PHP Extension β†’ Rust Rust core 31,219 πŸ† 2.6x
Raw PDO PHP Prepared statements 31,271 2.6x
Eloquent-like PHP PDO + model hydration 11,537 baseline

πŸš€ QAIL β‰ˆ PDO in single-query mode!

Pipeline mode + direct wire protocol = no libpq overhead

🐹 Go Driver (CGO)

CGO calling Rust static library β€’ 1,000 queries per batch

Driver Implementation Queries/Second vs GORM
pgx Go Pure Go, optimized 239,000 πŸ† 8.8x
qail-go Go CGO β†’ Rust Rust core 126,000 4.2x
GORM Go ORM overhead 27,000 baseline

πŸ“Š 4.2x faster than GORM

CGO overhead limits vs pure Go pgx β€’ Still much faster than ORMs!

⚑ Zig vs pg.zig (Fair Comparison)

Both drivers parse responses β€’ Apples-to-apples comparison

πŸ“– The Benchmark Story

Initial tests showed QAIL-Zig was 2.1x faster than pg.zig. But waitβ€”was this a fair comparison?

  • pg.zig: Uses Extended Query protocol (4 messages), parses responses, extracts typed values
  • QAIL-Zig (initial): Simple Query protocol, no response parsingβ€”only encoding!

So we built response parsing FFI to make it fair. Result? Still 2x faster!

Driver Work Done Queries/Second Rows Parsed
QAIL-Zig ⚑ Zig + Rust FFI β†’ Parse responses 33,866 πŸ† 55,000
pg.zig Pure Zig β†’ Parse responses 16,990 55,000

πŸ”§ What We Built

Response Parsing FFI
qail_decode_response()
qail_response_get_i32()
qail_response_get_string()
qail_response_free()
Linker Fix

Static library (119MB) caused segfaults.
Dynamic library (1.7MB) works perfectly!

πŸ”₯ QAIL-Zig is 2.0x faster (fair comparison!)

Both parse 55,000 rows β€’ Same I/O work β€’ Rust-optimized parsing wins

Why is QAIL Still Faster?

1. Simple Query Protocol

1 message vs 4 messages (Parse, Bind, Execute, Sync)

2. Rust-Optimized Parsing

Battle-tested wire protocol decoder from qail-pg

3. Zero Allocation

QAIL reuses buffers; pg.zig allocates per-query

πŸ“Š Cross-Language Summary

Driver Query Speed vs ORM % of Rust
Native Rust 354K q/s πŸ₯‡ N/A 100%
qail-zig 34K q/s 2.0x pg.zig N/A*
qail-php (single) 31K q/s 2.6x Eloquent 9%
qail-go (CGO) 126K q/s 4.2x GORM 36%
qail-py (PyO3) 122K q/s 7.6x asyncpg 35%
2.0x
Zig vs pg.zig
2.6x
PHP vs Eloquent
7.6x
Python vs asyncpg
4.2x
Go vs GORM

Try QAIL Today

The fastest database driver for PHP, Python, Go, and Rust.

Star on GitHub

← Back to all benchmarks