A PostgreSQL extension toolkit written in Rust, featuring a high-performance Key-Value store and Queue implementation backed by PostgreSQL.
Benchmarks were conducted on a local macOS environment comparing pg-ext (using Unlogged tables for performance) against a local Redis instance.
- OS: macOS
- System: Local Development Machine
- PostgreSQL: Local instance (Unix domain socket / localhost)
- Redis: Local instance (127.0.0.1:6379)
- Tool: Criterion.rs
- Date: 2024 (Current)
| Operation | pg-ext (Unlogged) | Redis | Ratio (Redis / pg-ext) |
|---|---|---|---|
| SET | ~11.0k ops/s | ~26.7k ops/s | ~2.4x |
| GET | ~12.7k ops/s | ~27.5k ops/s | ~2.2x |
| INCR (Atomic) | ~11.4k ops/s | ~25.7k ops/s | ~2.2x |
| MSET (10 items) | ~91.7k items/s | ~249.1k items/s | ~2.7x |
| MGET (10 items) | ~93.9k items/s | ~223.1k items/s | ~2.4x |
| RPUSH (Queue) | ~10.2k ops/s | ~27.0k ops/s | ~2.6x |
| Push/Pop (Roundtrip) | ~5.3k ops/s | ~12.8k ops/s | ~2.4x |
pg-ext achieves approximately 40-50% of Redis performance for raw Key-Value
operations. Considering pg-ext provides full SQL consistency (tunable) and persists
data within PostgreSQL's robust storage engine, these results demonstrate that
pg-ext is a viable alternative to Redis for applications already using PostgreSQL,
eliminating the need for a separate infrastructure component for caching or simple
queueing needs.
Note: pg-ext tests used UNLOGGED tables to approximate cache-like behavior
(persistence across restarts, but not crash-safe), which is the closest comparison
to default Redis persistence.
- Ensure Postgres and Redis are running locally.
- Create a database named
pgext. - Run the benchmark command:
cargo bench