narrowdb
A lightweight columnar database for log and time-series data, written in Rust.
Quick start
# Create a table and insert data
# Query with filters, aggregation, and ordering
As a library
[]
= "0.1"
use ;
let mut db = open?;
db.execute_sql?;
db.insert_rows?;
let results = db.execute_sql?;
TCP server
The repo also includes a separate runnable server crate in crates/server.
It speaks the PostgreSQL wire protocol over TCP with password auth.
Example connection:
PGPASSWORD=secret
Example SQL:
(ts TIMESTAMP, service TEXT, status INT);
INSERT INTO logs VALUES (1, 'api', 200);
SELECT * FROM logs;
Benchmarks
10M rows, 9 columns, Apple Silicon, release build (cargo run --release --bin bench-narrow -- 10000000):
| Metric | NarrowDB | DuckDB | Delta |
|---|---|---|---|
| Ingest throughput | 7.2M rows/s | 1.4M rows/s | 5x faster |
| Storage size | 59.6 MiB (6.3 B/row) | 90.3 MiB (9.5 B/row) | 34% smaller |
| Filter + GROUP BY | 3.3ms | 5.9ms | 1.8x faster |
| Filter + GROUP BY + AVG | 4.1ms | 5.1ms | 1.2x faster |
| Filter + COUNT | 3.7ms | 6.5ms | 1.8x faster |
License
MIT