π 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) | 31,219 π | 2.6x | |
| Raw PDO | 31,271 | 2.6x | |
| Eloquent-like | 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 | 239,000 π | 8.8x | |
| qail-go | 126,000 | 4.2x | |
| GORM | 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% |
Try QAIL Today
The fastest database driver for PHP, Python, Go, and Rust.
Star on GitHub