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
# Rename and drop tables
# Inspect metadata
As a library
[]
= "0.3.1"
use ;
let mut db = open?;
db.execute_sql?;
db.insert_rows?;
let results = db.execute_sql?;
For larger ingests, prefer:
insert_rows_iter(...)when your source is row-oriented and you want to stream rows without collecting a giantVec<Vec<Value>>insert_columnar_batch(...)withColumnarBatchBuilderwhen your source is already column-shaped or you want maximum throughput
Examples:
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, including prepared statements and parameter binding. MD5 auth should be treated as trusted-network only.
Example connection:
PGPASSWORD=secret
Example SQL:
(ts TIMESTAMP, service TEXT, status INT);
INSERT INTO logs VALUES (1, 'api', 200);
SELECT * FROM logs;
Benchmarks
1M rows, 9 columns, Apple Silicon, release build:
| Metric | NarrowDB | DuckDB | Delta |
|---|---|---|---|
| Ingest throughput | 6.61M rows/s | 1.81M rows/s | 3.65x higher |
| Storage size | 5.97 MiB (6.26 B/row) | 9.01 MiB (9.45 B/row) | 1.51x smaller |
| Filter + GROUP BY | 536µs | 2.17ms | 4.05x faster |
| Filter + GROUP BY + AVG | 475µs | 1.39ms | 2.93x faster |
| Filter + COUNT | 553µs | 912µs | 1.65x faster |
| Projection-heavy scan | 1.59ms | 1.42ms | DuckDB 1.12x faster |
| High-cardinality grouped count | 1.32ms | 1.19ms | DuckDB 1.11x faster |
| Cross-row-group string group by | 1.13ms | 2.04ms | 1.80x faster |
Development
For full docs, see docs/README.md. For build, test, lint, benchmark, and release commands, see CONTRIBUTING.md.
License
MIT