r/dotnet • • 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.

11 Upvotes

Duplicates