Prax is highly optimized for performance, matching Diesel for type-level operations while providing a developer-friendly Prisma-like API.
| Operation | Prax | Diesel | SQLx | Notes |
|---|---|---|---|---|
| Simple SELECT | 40ns | 278ns | 5ns | 7x faster than Diesel |
| SELECT + filters | 105ns | 633ns | 5ns | 6x faster than Diesel |
| INSERT query | 81ns | - | 5ns | - |
| UPDATE query | 101ns | - | 5ns | - |
| Operation | Prax (TypeLevel) | Prax (Runtime) | Diesel | Notes |
|---|---|---|---|---|
| Simple filter | 2.1ns | 7ns | 4.7ns | DirectSql: 2.1ns |
| AND (2 filters) | 4.3ns | 17ns | 5ns | DirectSql matches Diesel |
| AND (5 filters) | 5.1ns | 32ns | 5ns | TypeLevel = Diesel! |
| AND (5) SQL gen | 17ns | - | - | DirectSql write |
| IN (10 values) | 3.8ns | 21ns | 14ns | Pre-computed pattern |
| IN (32 values) | 5.0ns | - | - | Pre-computed pattern |
| IN (100 values) | 158ns | 160ns | - | Looped generation |
| Operation | Prax | SQLx | Diesel-Async | Winner |
|---|---|---|---|---|
| SELECT by ID | 193µs | 276µs | 6.18ms* | Prax |
| SELECT filtered | 192µs | 269µs | 7.40ms* | Prax |
| COUNT | 255µs | 320µs | - | Prax |
| SELECT prepared | 191µs | - | - | Prax |
* Diesel-Async establishes a new connection per iteration (~6ms overhead). Prax and SQLx use connection pooling with warmup.
| Type | Size | Notes |
|---|---|---|
| Filter | 64 bytes | Fits in single cache line |
| ValueList | 24 bytes | 91% reduction from SmallVec |
| FieldName | 24 bytes | Cow<'static, str> |
Zero-allocation SQL generation directly from typed filters.
256-entry static lookup table for PostgreSQL placeholders ($1, $2, ...). Pre-computed IN patterns for 1-32 elements.
Cache query plans with performance hints and automatic execution time tracking.
Borrow string data directly from database rows without allocating.
Combine multiple queries into a single database round-trip.
Stack-allocated filter composition matching Diesel's zero-cost abstractions.
Filter enum fits in a single 64-byte cache line.
Static field names and pre-computed values avoid heap allocation.
Pre-establish connections and prepare statements at startup.
All queries use prepare_cached() for per-connection statement reuse.