r/dotnet • u/arintonakos12 • 1d ago
Promotion DataVo v0.4: an open-source embedded SQL, vector, and reactive DB engine in pure C# (beating SQLite and DuckDB on hot-path lookups & IVM)
For the last 9 months I've been building DataVo, an embedded database written entirely in C# on .NET 10. There are no native binaries, so no P/Invoke and no UTF-8/UTF-16 conversion on every string. It publishes with Native AOT and zero trim warnings.

The idea I kept coming back to: a lot of what a query engine does at runtime can happen at build time. Roslyn source generators and LINQ interceptors turn [DataVoTable] types and [DataVoQuery] methods into code that reads straight out of byte buffers. No reflection, no expression trees compiled at runtime.
Here is what that looks like in practice:
[DataVoTable("players")]
public sealed class Player
{
[PrimaryKey] public int Id { get; set; }
public string Name { get; set; } = "";
}
var players = db.Table<Player>();
// Point lookup. The interceptor rewrites this call site at build time.
Player? p = players.FirstOrDefault(42, static (p, key) => p.Id == key);
// Filtered count over a [Columnar] column, 0 B allocated per call.
int elites = players.Where(1000, static (p, min) => p.Score >= min).Count();The lambdas are static and take their argument as explicit state, which is what lets the generator compile them. If it can't translate one, you get a build warning and it falls back to a slower path that still returns exact results.
Numbers from one Apple M4 Pro, 100,000 rows, BenchmarkDotNet (methodology and raw output are in the write-up):
Primary-key lookup in memory: 55 ns for DataVo, 716 ns for SQLite.
Primary-key lookup on disk (DataVo LSM vs SQLite WAL): 216 ns vs 1,654 ns.
Filtered COUNT/SUM/MIN/MAX over 200,000 rows through compiled LINQ: no allocation, about 9 to 10 times faster than SQLite.
It loses too. GROUP BY over 125,000 groups of an indexed key, unindexed ORDER BY ... LIMIT, and full scans with OR or LIKE are slower than SQLite. DuckDB is faster than both of us on anything that reads the whole table. On a durable write, both DataVo and SQLite wait for the same ~4 ms fsync, so the lookup speedup doesn't matter there.
Other things in 0.4:
Large scans stream in 1,024-row pages. StreamRef() yields stack-only RowRef spans over reused buffers, so it allocates 0 bytes per row after warmup.
Live reactive views built on delta batches (DBSP-style), with SubscribeInto writing into a Memory<T> you own.
VECTOR(n) columns with FLAT and HNSW indexes (SIMD) in the same transaction log.
An ADO.NET provider that works with Dapper.
The disk engine is an LSM with a WAL and memory-mapped SSTables.
What it isn't: not client/server, one process owns the database directory, transactions are snapshot isolation (not serializable), and the SQL dialect is its own.
MIT licensed. DataVo.Data 0.4.0-rc.1 is on NuGet.
Source: https://github.com/ArintonAkos/DataVo-DBMS
Benchmarks, including the losses: https://arintonakos.github.io/DataVo-DBMS/blog/part-1-where-it-wins-and-where-it-loses
If you do Native AOT or local-first work, what's the first query you would throw at it? I would rather get a failing one than a polite reply.
2
u/anthemfor182 1d ago
Interesting, I'm also building an embedded key/value store in plain c# called Solarium (mostly following similar motivations against native rocksdb)
question, the research notes on "Are You Sure You Want to Use mmap in Your DBMS?" advise against mmap for the row store, what made you choose it for the sstables? also, if a block's crc is only checked the first time it's touched, what happens when the os drops that page and later reads back damaged data?
1
u/arintonakos12 1d ago
That CIDR '22 paper is the reason
LsmReadModein DataVo is configurable (AutovsPositionalRead) instead of hardcoded.The paper's main warnings are about read-write buffer pools (like MMAPv1) flushing dirty pages out of WAL order, and multi-terabyte out-of-core datasets where synchronous page faults stall worker threads. DataVo's SSTables avoid most of that because it never writes through
mmap. Mutations go sequentially throughcommit.waland an arena MemTable, and new.sstfiles are written sequentially,fsynced, and atomically renamed before being mapped read-only. DataVo also targets local-first and embedded workloads (tens of MBs to a few GBs, e.g. ~28 MB per 1M rows) that mostly stay warm in the OS page cache. Skipping a syscall and an extra kernel-to-managed buffer copy on every lookup is what gets LSM point lookups down to ~216 ns and columnar scans to 0 B heap allocation without double-buffering in client apps.
LsmReadMode.Autoonly maps on 64-bit platforms, and you can switch toLsmReadMode.PositionalReadto useRandomAccess.Read(pread) on 32-bit targets, removable media, or workloads where you want explicit I/O error handling instead ofSIGBUS. On theVerifyOncepoint, you're right: if the OS evicts a clean mapped page and later re-reads corrupted bytes from disk,VerifyOncecurrently skips the CRC re-check. Adding an optional user-space block cache overPositionalReadis high on the list for0.5.0, which would also let us add block-level LZ4/Zstd compression and avoid those post-eviction CRC andSIGBUSedge cases.2
u/harrison_314 1d ago
Haven't you tried https://github.com/ZoneTree/ZoneTree I built a time-series database on it.
2
u/Discordbothost 1d ago
I'd try the FirstOrDefault key lookup in the published AOT binary against LSM. Insert 42, reopen and look it up, then delete it and reopen again. The smoke test checks a miss in memory. This would check that the same lookup still returns null after a persisted delete.
0
u/AutoModerator 1d ago
Thanks for your post arintonakos12. Please note that we don't allow spam, and we ask that you follow the rules available in the sidebar. We have a lot of commonly asked questions so if this post gets removed, please do a search and see if it's already been asked.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
3
u/wubalubadubdub55 1d ago
This looks interesting!