tickdb
A distributed tick-data database in Rust, written from scratch. It started up to 22x behind DuckDB. After profiling it, it beats DuckDB on 1-minute bars and trails by 1.3–1.5x on the rest, and this page shows how both happened.
The honest benchmark
I benchmark tickdb against DuckDB on 2,000,000 synthetic trades. The numbers below are from December 2026, on a MacBook Air with an Apple M5 (10 cores, 16 GB), with both engines using all 10 cores. Each is the median of ten warm runs, measured twice.
When I first wrote this page, DuckDB beat tickdb on every query, by up to 22x. So I profiled it, found where the time went, and fixed it one change at a time. tickdb now wins 1-minute bars and is close on the rest.
The same runs as numbers:
| tickdb | DuckDB | Result | |
|---|---|---|---|
| OHLCV, 1‑minute bars | 6.8 ms | 15.7 ms | tickdb about 2.3x faster |
| VWAP, full range | 4.0 ms | 2.6–2.9 ms | DuckDB 1.4–1.5x faster |
| Top 10 by volume | 5.1–5.2 ms | 3.9–4.0 ms | DuckDB about 1.3x faster |
| Ingest, 2M rows | 111–115 ms | 90–100 ms | about even |
| Size on disk | 6.50 bytes/trade | 8.13 bytes/trade | tickdb 20% smaller |
How to read that:
- The win comes from knowing the data is sorted by time. tickdb stores each symbol’s trades in timestamp order, so building 1-minute bars is one pass where about 60 rows in a row land in the same bar. DuckDB can’t assume a file is sorted, so it runs a general hash aggregation.
- DuckDB still wins VWAP and top 10, and per core it’s further ahead. On one thread each, DuckDB is about 2.5x faster on both. Parquet stores each column on its own, so DuckDB reads only the columns a query needs, while my format compresses all five columns together to stay small. Closing that gap means changing the file format, not the code.
- DuckDB gets its best shot. Its OHLCV time uses the fastest correct SQL I found (
arg_min/arg_maxover integer buckets). The SQL I first published took about twice as long, which made DuckDB look worse than it is. - I caught myself overclaiming, again. A draft said tickdb was 2.6x faster on OHLCV. Part of DuckDB’s time was Python turning 33,333 result rows into Python objects, a cost tickdb never pays. Timed with columnar output instead, the gap at that point was 1.8x. The 2.3x above is after two more changes, measured the same fair way.
- I retracted a claim before. In July an early run had tickdb about 3x faster than DuckDB on OHLCV. It came from a starved test machine and I couldn’t reproduce it, so I took it out.
- Ingest isn’t fully apples to apples. tickdb’s number is its whole write path (parse, write-ahead log, memtable, flush) with the log not synced to disk. DuckDB’s is a CSV load into memory.
- One laptop, synthetic data. I haven’t run these on real exchange data, other machines, data bigger than memory, or many queries at once.
What made it faster
Eight changes, each its own commit with before-and-after numbers, and one I reverted because the gain was inside the noise:
- Decode only the columns a query reads. VWAP needs price and size, not all five columns.
- Build OHLCV bars per run of rows, not per row: one map lookup per bar instead of one per trade.
- Skip trades that can’t make the top 10 before touching the heap.
- Work on blocks in parallel across all cores, then merge the partial results in block order, so the answer is bit-for-bit the same at any thread count.
- Decompress each block in one shot, decode size columns in batches, and write and parse in parallel on ingest.
Every change kept the answers identical, checked against a naive reference implementation, and the test count went from 207 to 266.
The problem
Tick data is every trade on a market: a timestamp, a price, a size and a side. It arrives in time order, there is a lot of it, and almost every question you ask of it is “roll this up into bars” or “what was the price as of this moment.”
I wanted to build the whole stack under those questions myself: the bytes on disk, crash recovery, the query loops and the replication. It’s a systems project, not something I’d tell anyone to run in production.
What I built
- A file format. Timestamps are delta-of-delta encoded, prices are delta plus zigzag, the buy/sell side is run-length encoded, and blocks are compressed with Zstd.
- A storage engine. A write-ahead log, a memtable, a manifest, memory-mapped segments and size-tiered compaction.
- Query kernels. OHLCV bars, VWAP, top-N and an as-of join done as a two-pointer merge. Each one is checked against a naive reference implementation across 50 seeds.
- Raft, from scratch. The node is a pure
stepfunction with no I/O, so I can run it inside a deterministic simulator. The simulator ran 1,000 seeded campaigns of dropped, delayed and duplicated messages, partitions and crashes with zero invariant violations. It also does log compaction with leader-installed snapshots. - A server. An HTTP API on Axum that streams results as Arrow IPC, and a real TCP transport for Raft. Outside the simulator I’ve run it as three processes on localhost, where killing the leader got a new one elected in 300 ms with both survivors’ data byte-for-byte unchanged, and as a three-node Docker Compose cluster.
It’s a 7-crate Cargo workspace with 266 passing tests.
What’s broken or unfinished
- The kill-the-leader test hasn’t run inside Docker. The three-node Compose cluster comes up clean, but the chaos script’s kill, re-elect and catch-up sequence has only been checked on the localhost cluster.
- The as-of join probably has a range-filter bug on flushed data. I found it while profiling and logged it; it isn’t fixed yet.
- Synthetic data only. The benchmark is 2M generated rows. The script to pull real Binance trades exists and I haven’t run the numbers on it.
- The as-of join has no DuckDB comparison, so I don’t claim anything about it either way.
What I’d do next
- Change the file format so each column decompresses on its own. That’s the remaining gap on VWAP and top 10.
- Rerun every benchmark on real trade data.
- Fix the as-of join bug, then benchmark the as-of join against DuckDB.
- Run the chaos script against the Docker cluster.