Expand description
§QAIL PostgreSQL Driver
The world’s first AST-native PostgreSQL driver.
No SQL strings. No ORM. Direct wire protocol encoding from typed AST.
§Performance
- Sequential: 33K queries/sec (1.3x faster than tokio-postgres)
- Pipelined: 347K queries/sec (12.8x faster than tokio-postgres)
§Architecture
QailCmd (AST) → PgEncoder → BytesMut → TCP → PostgreSQL§Layer 2: Protocol (Pure, Sync)
PgEncoder- Compiles QailCmd directly to wire protocol bytes- No async, no I/O, no tokio, no SQL string generation
- Input: AST → Output: BytesMut
§Layer 3: Driver (Async I/O)
PgConnection- TCP/TLS/Unix socket networking- Production-ready connection pooling (
PgPool) - Prepared statement caching
- Wire-level pipelining for batch operations
§Features
- TLS/SSL support via rustls
- Connection pooling with health checks
- Wire-level pipelining for 10x+ throughput
- Prepared statement caching with auto-hashing
- Full type system (UUID, JSON, Date/Time, Numeric, Arrays)
§Example
ⓘ
use qail_core::ast::QailCmd;
use qail_pg::PgDriver;
// Build query as typed AST
let cmd = QailCmd::get("users")
.column("id")
.column("email")
.filter("active", Operator::Eq, true);
// Execute (AST → wire bytes → PostgreSQL → rows)
let mut driver = PgDriver::connect("localhost", 5432, "user", "db").await?;
let rows = driver.fetch_all(&cmd).await?;Re-exports§
pub use driver::PgConnection;pub use driver::PgDriver;pub use driver::PgDriverBuilder;pub use driver::PgError;pub use driver::PgPool;pub use driver::PgResult;pub use driver::PgRow;pub use driver::PoolConfig;pub use driver::PoolStats;pub use driver::PooledConnection;pub use protocol::PgEncoder;pub use types::Date;pub use types::FromPg;pub use types::Json;pub use types::Numeric;pub use types::Time;pub use types::Timestamp;pub use types::ToPg;pub use types::TypeError;pub use types::Uuid;