Matches Diesel for type-level filters

# Performance

Prax is highly optimized for performance, matching Diesel for type-level operations while providing a developer-friendly Prisma-like API.

## Key Achievements

5.1ns
Type-level AND(5)
Matches Diesel!
3.8ns
IN(10) SQL generation
5.8x faster with patterns
64B
Filter enum size
Fits in single cache line
30%
Faster than SQLx
Database execution

## Query Building Performance

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 | -

## Filter Construction Performance

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

## Database Execution (PostgreSQL with Pooling)

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.

## Memory Footprint

Type | Size | Notes
--- | --- | ---
Filter | 64 bytes | Fits in single cache line
ValueList | 24 bytes | 91% reduction from SmallVec
FieldName | 24 bytes | Cow<'static, str>

## Optimization Techniques

### DirectSql Trait (~5ns)

Zero-allocation SQL generation directly from typed filters.

### Pre-computed Placeholders

256-entry static lookup table for PostgreSQL placeholders ($1, $2, ...). Pre-computed IN patterns for 1-32 elements.

### Execution Plan Cache

Cache query plans with performance hints and automatic execution time tracking.

### Zero-Copy Row Deserialization

Borrow string data directly from database rows without allocating.

### Pipeline Execution

Combine multiple queries into a single database round-trip.

### Type-Level Filters (And5, Or5)

Stack-allocated filter composition matching Diesel's zero-cost abstractions.

## Why Prax is Fast

### Cache-Friendly Layout

Filter enum fits in a single 64-byte cache line.

### Zero Allocation Paths

Static field names and pre-computed values avoid heap allocation.

### Connection Pool Warmup

Pre-establish connections and prepare statements at startup.

### Prepared Statement Caching

All queries use prepare_cached() for per-connection statement reuse.

## Prax vs Diesel

### Where Prax Wins

- ✓ 6-7x faster SQL string construction
- ✓ TypeLevel filters match Diesel (5.1ns vs 5ns)
- ✓ 30% faster database execution vs SQLx
- ✓ Runtime flexibility with Prisma-like API
- ✓ Pre-computed IN patterns (3.8ns for 10 values)

### Where They're Equal

- ≈ Type-level AND(5): 5.1ns vs 5ns
- ≈ DirectSql trait matches zero-cost abstractions
- ≈ 64-byte Filter vs Diesel's type-level size