A comprehensive benchmark suite demonstrating SQLite's performance characteristics for edge computing binaries using Rust and SQLX.
This project was done to validate the performance claims made in my blog post "SQLite at the Edge: When To Choose A Local Database Persistence Layer" by trying to re-implement a scenario I had at a client project. This benchmark measures:
- Single vs Batch Insert Performance
- Concurrent Read Performance
- PRAGMA Optimization Impact
- Index Performance Trade-offs
- WAL Checkpoint Performance
-
Dual-Pool Architecture: Separate read/write pools following SQLite best practices
-
Production-Grade Optimizations: Implements all PRAGMA settings from
-
Comprehensive Metrics: Measures latency percentiles, throughput, and resource usage
-
File based database and comparision with in-memory db
Based on the blog post research, this benchmark suite validates:
- 10,000+ messages/second sustained throughput
- Sub-millisecond query latency for indexed lookups
- Concurrent read scaling with WAL mode
- Batch insert optimization (100-1000x improvement over single inserts)
- Rust 1.70+
- SQLite 3.38+
git clone https://github.com/yourusername/sqlx-sqlite-benchmark
cd sqlx-sqlite-benchmark
cargo build --release
# Quick demonstration with 10,000 sensor readings (in-memory)
DATABASE_URL=sqlite::memory: cargo run --release -- --demo
# Demo with file database
DATABASE_URL=sqlite:demo.db cargo run --release -- --demo
# Run complete benchmark suite (in-memory database)
DATABASE_URL=sqlite::memory: cargo run --release -- --benchmark
# Run with file database
DATABASE_URL=sqlite:benchmark.db cargo run --release -- --benchmark
# Custom configuration with reduced records for testing
DATABASE_URL=sqlite::memory: cargo run --release -- --benchmark \
--iterations 3 \
--total-records 10000
The DATABASE_URL
environment variable is required and supports:
- In-memory database:
sqlite::memory:
- File database:
sqlite:path/to/database.db
Important: Always set DATABASE_URL
before running any commands. The application will exit with an error message if this is not set.
Performance targets assume:
- NVMe SSD storage (3-5x faster than SATA SSD)
- 8GB+ RAM for effective page caching
- Modern multi-core CPU
- ext4 filesystem with
noatime
mount options
- Storage Type: NVMe > SATA SSD > HDD (3-10x differences)
- Batch Size: 100-1000x improvement over single inserts
- Indexing: 10-100x query speedup, 20% write overhead
- Cache Size: Diminishing returns above working set size
- WAL Mode: Enables concurrent reads, slight write overhead
- Fork the repository
- Create a feature branch
- Add benchmark scenarios or optimizations
- Submit pull request with performance analysis
MIT License - see LICENSE file for details.