ShrestiDB is an embedded database kernel that replaces bulky B-Trees with learned regression models and SIMD vector search — delivering 8x–10x faster lookups and a 4x smaller memory footprint in a single binary.
Treats key indexing as an ML regression problem. Predicts exact tuple offsets with bounded linear segments, scaling flatly at O(log ε) while saving 75% RAM over B-Trees.
High-dimensional embeddings with Hierarchical Navigable Small World (HNSW) proximity graphs. Accelerated by AVX2/NEON SIMD cosine, L2, and dot product distances.
Snapshot-isolated transactions with row-level 2PL and write-ahead logging (WAL). Online regression models predict version bloat to sweep dead tuples without manual VACUUM.
Reproducible with cargo run --release --example learned_index_demo
| Dataset Scale | Learned PGM Lookup | Learned RMI Lookup | Standard B+Tree | PGM Speedup | Index Memory Footprint |
|---|---|---|---|---|---|
| 10,000 Keys | 0.55 µs | 0.18 µs | 0.10 µs | 0.5x | ~4x smaller |
| 100,000 Keys | 0.41 µs | 0.22 µs | 0.30 µs | 0.7x | ~4.1x smaller |
| 1,000,000 Keys | 0.44 µs | 0.37 µs | 3.61 µs | 8.2x – 9.8x FASTER | 75% Less RAM (~4.2x) |
-- Unified structured metadata + vector search SELECT a.name, addr.city, a.embedding <=> '[0.90, 0.15, 0.05]' AS distance FROM accounts a JOIN address addr ON a.id = addr.id WHERE a.balance > 3000 ORDER BY distance LIMIT 5;
use shrestidb::execution::QueryExecutor; fn main() -> anyhow::Result<()> { // Durable engine backed by Write-Ahead Log (WAL) let db = QueryExecutor::open("shrestidb.wal")?; // Execute SQL statements directly let rows = db.execute_sql( "SELECT * FROM accounts WHERE balance >= 5000;" )?; Ok(()) }