monoio-pg
High-performance asynchronous PostgreSQL driver for the monoio runtime.
Features
- io_uring support: Leverages
monoio's efficientio_uringbased asynchronous I/O. - Thread-per-core: Optimized for high-throughput, low-latency performance in a thread-per-core architecture.
- Handshake & Auth: Supports standard PostgreSQL handshake and authentication (including SCRAM-SHA-256).
- Extended Query Protocol: Full support for
parse,bind, andexecute. - Zero-Copy Architecture: Minimized memory allocations and data copying during query processing.
- Implicit Statement Caching: Automatically reuses parsed statements and row descriptions for maximum efficiency.
- Automatic CI/CD: Fully automated versioning and publishing to crates.io on every push.
Usage
use Client;
async
Performance
monoio-pg is built for extreme performance. In our benchmarks (running 100 queries per iteration), it consistently outperforms tokio-postgres by 1.7x to 2.2x.
| Benchmark Scenario | monoio-pg (Avg) |
tokio-postgres (Avg) |
Speedup |
|---|---|---|---|
Small Query (SELECT 1) |
1.97 ms | 6.57 ms | 3.33x Faster |
| Wide Row (10 columns) | 2.08 ms | 7.10 ms | 3.41x Faster |
| Large Result (100 rows) | 3.59 ms | 7.93 ms | 2.20x Faster |
Visual Comparison (Higher is Better)
Postgres Query Throughput (Higher is Better)
--------------------------------------------
Small Query (SELECT 1)
monoio-pg ████████████████████ 50,761 req/s
tokio-postgres ██████ 15,220 req/s
Wide Row (10 columns)
monoio-pg ████████████████████ 48,076 req/s
tokio-postgres ██████ 14,084 req/s
Large Result (100 rows)
monoio-pg ███████████ 27,855 req/s
tokio-postgres █████ 12,610 req/s
Benchmarks performed on a thread-per-core configuration comparing
monoiowith theFusiondriver vstokio.
Roadmap
The goal of monoio-pg is to become the fastest, most reliable PostgreSQL driver for the Rust ecosystem.
- Benchmarks: Comprehensive performance comparisons against
tokio-postgres. - Statement Caching: Implicit management of prepared statements and row descriptions.
- TLS Support: Integration with
native-tlsandrustls. - Transaction Management: Support for nested transactions and savepoints.
- Copy Protocol: High-performance data ingestion with
COPY. - Notifications: Support for
LISTENandNOTIFY. - Portal Support: Partial result fetching and cursors.
- Complex Types: Native support for JSONB, Arrays, and Range types.
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
License
WTFPL