<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Rust on MongrelDB</title><link>https://www.mongreldb.com/articles/tags/rust/</link><description>Recent content in Rust on MongrelDB</description><image><title>MongrelDB</title><url>https://www.mongreldb.com/logo.png</url><link>https://www.mongreldb.com/logo.png</link></image><generator>Hugo</generator><language>en-US</language><lastBuildDate>Tue, 07 Jul 2026 21:00:00 -0500</lastBuildDate><atom:link href="https://www.mongreldb.com/articles/tags/rust/index.xml" rel="self" type="application/rss+xml"/><item><title>MongrelDB: What It Is, What It Isn't, and Where It Fits</title><link>https://www.mongreldb.com/articles/2026/07/mongreldb-what-it-is-what-it-isnt-and-where-it-fits/</link><pubDate>Tue, 07 Jul 2026 21:00:00 -0500</pubDate><guid>https://www.mongreldb.com/articles/2026/07/mongreldb-what-it-is-what-it-isnt-and-where-it-fits/</guid><description>&lt;p&gt;Twenty years ago I was writing PHP 5 code that talked to MySQL 4.1 through &lt;code&gt;mysql_*&lt;/code&gt;. The whole stack was a LAMP box, a single MySQL server, an &lt;code&gt;.htaccess&lt;/code&gt; file, and a prayer. Back then &amp;ldquo;embedded database&amp;rdquo; basically meant SQLite or nothing, and SQLite was for client apps, not production server work.&lt;/p&gt;
&lt;p&gt;Things have changed. The embedded database category has real options now — SQLite (which grew up and got serious), DuckDB (analytical powerhouse), libSQL (SQLite&amp;rsquo;s networked fork), RocksDB and LMDB (KV primitives), and now MongrelDB. I want to talk about this last one because it does something genuinely different.&lt;/p&gt;</description><content:encoded><![CDATA[<p>Twenty years ago I was writing PHP 5 code that talked to MySQL 4.1 through <code>mysql_*</code>. The whole stack was a LAMP box, a single MySQL server, an <code>.htaccess</code> file, and a prayer. Back then &ldquo;embedded database&rdquo; basically meant SQLite or nothing, and SQLite was for client apps, not production server work.</p>
<p>Things have changed. The embedded database category has real options now — SQLite (which grew up and got serious), DuckDB (analytical powerhouse), libSQL (SQLite&rsquo;s networked fork), RocksDB and LMDB (KV primitives), and now MongrelDB. I want to talk about this last one because it does something genuinely different.</p>
<h2 id="what-mongreldb-is">What MongrelDB is</h2>
<p>MongrelDB is an embedded, single-node, log-structured columnar database written in Rust. The name is a deliberate riff on MongoDB — and the joke is the point. A mongrel is a mixed-breed dog, and MongrelDB takes the good parts from several places and bolts them together. Some of those bolts are welded; some are still held on with baling wire. We&rsquo;ll get to which is which.</p>
<p>The headline numbers from the project&rsquo;s own cross-engine benchmarks at 1M rows:</p>
<ul>
<li>Single-row durable write: <strong>7.7 µs</strong> — about 1.8× faster than SQLite (14.2 µs), 37× faster than DuckDB (301 µs)</li>
<li>Single-row durable update: <strong>7.4 µs</strong></li>
<li>Bulk insert: 2.3× SQLite, 2.6× DuckDB native</li>
<li><code>COUNT(*)</code> is O(1) by design — 0 µs</li>
<li>Storage: 4.17 bytes/row at 1M rows</li>
</ul>
<p>Take vendor benchmarks with the usual grain of salt, but these aren&rsquo;t outlandish. The architecture backs them up.</p>
<h2 id="how-its-built-and-why-it-matters">How it&rsquo;s built (and why it matters)</h2>
<p>Write path: a WAL feeds a Bε-tree memtable, which flushes to immutable sorted runs in a custom <code>.sr</code> PAX columnar format. Read path: merge memtable + sorted runs under MVCC snapshot isolation. This is LSM with some twists.</p>
<p>The unusual part is the <strong>eight index kinds</strong> in a shared RowId space:</p>
<ul>
<li><strong>HOT</strong> — trie for primary-key point lookup</li>
<li><strong>Bitmap</strong> — Roaring for low-cardinality equality</li>
<li><strong>PGM</strong> — learned range index (shrinking-cone, ε-bounded)</li>
<li><strong>FM-index</strong> — BWT + wavelet tree for substring / FTS</li>
<li><strong>HNSW</strong> — approximate nearest neighbor for vectors</li>
<li><strong>PMA</strong> — cache-oblivious sorted runs</li>
<li><strong>Sparse</strong> — inverted token lists for learned-sparse retrieval</li>
<li><strong>MinHash</strong> — LSH for set similarity (dedup / join)</li>
</ul>
<p>You compose conditions in RowId space, then decode only the matching rows and the columns you asked for. That hybrid model — bitmap equality intersected with HNSW ANN intersected with FM substring — is what modern AI retrieval actually needs. Most embedded engines give you a B-tree and a hash index and call it done.</p>
<p>Predicate and projection pushdown go all the way to the page level. Each 65,536-row page carries populated min/max; the reader skips whole pages whose range excludes your predicate. Encrypted columns keep their min/max in a per-run AES-256-GCM stats envelope, so they prune identically to plaintext. The 1.87 GiB/s AES throughput is hardware-accelerated and adds under 5% to typical workloads.</p>
<p>The SQL frontend is <strong>DataFusion 54</strong>, which means recursive CTEs, window functions, <code>CREATE TABLE AS SELECT</code>, materialized views, multi-statement execution, and a <code>mongreldb_fts_rank</code> UDF for FTS ranking. You can embed the engine in-process (the better-sqlite3 model) or run an optional <code>mongreldb-server</code> daemon (axum/tokio) for multi-process access.</p>
<p>Around the engine you get real database features: WAL-streamed replication (read-scaling, not write-scaling), change data capture via <code>NOTIFY</code>/<code>LISTEN</code> + SSE, Argon2id user/role/<code>GRANT</code>, page-level AES-256-GCM encryption with a proper key hierarchy, and per-table unique / FK / CHECK constraints enforced <strong>in the core transaction path</strong> — not in your app code.</p>
<p>Language bindings are real, not vapor: Rust core, Node NAPI addon, pure-PHP 8.4+ (no C extension, talks HTTP to the daemon), Python and TypeScript via MongrelDB Kit (schema-aware query builder, migrations, multi-language parity, content-addressed migration checksums).</p>
<h2 id="where-it-fits-in-2026">Where it fits in 2026</h2>
<p>The embedded database market has roughly four niches:</p>
<ol>
<li><strong>OLTP embedded</strong> — SQLite, libSQL. Single-row writes, simple reads, durable, tiny footprint. SQLite is the 800-pound gorilla.</li>
<li><strong>OLAP embedded</strong> — DuckDB. Bulk reads, analytical queries, columnar. Wins on filter and aggregation throughput.</li>
<li><strong>KV embedded</strong> — RocksDB, LevelDB, LMDB. Lower-level primitives; you build indexes on top.</li>
<li><strong>AI-native storage</strong> — Qdrant, Lance, SQLite extensions. Optimized for vector search and learned indexes.</li>
</ol>
<p>MongrelDB is trying to sit across (1) and (4) with some of (2)&rsquo;s analytical chops. The pitch is: &ldquo;Your app&rsquo;s primary storage AND your vector search AND your FTS AND your learned-sparse retrieval, in one embedded engine, with no separate vector DB to sync.&rdquo;</p>
<p>That&rsquo;s a real pitch. The eight-index approach is what makes it more than marketing.</p>
<h2 id="the-pros">The Pros</h2>
<ul>
<li><strong>Writes are genuinely fast.</strong> Sub-10µs single-row durable writes in an embedded engine is a real achievement. SQLite is fast; this is faster. DuckDB isn&rsquo;t in the same race for OLTP.</li>
<li><strong>AI-native is not marketing.</strong> HNSW, Sparse, and FM-index are first-class indexes, not query-time hacks. The hybrid query model matches what AI retrieval actually needs.</li>
<li><strong>Encryption is built in, not bolted on.</strong> Page-level AES-256-GCM with a real key hierarchy (passphrase → Argon2id → KEK → DEK, or raw key file), HMAC&rsquo;d run metadata, and pruning preserved on encrypted columns.</li>
<li><strong>Constraints in the core.</strong> Unique, FK, and CHECK are enforced at the storage layer. Same for auth — <code>require_auth</code> makes the engine itself reject unauthenticated opens, not just the daemon front-door.</li>
<li><strong>The Rust + DataFusion choice is smart.</strong> Rust for memory safety and FFI ergonomics, DataFusion for the SQL parser/optimizer/planner. Years of battle-tested code you&rsquo;re not re-implementing.</li>
<li><strong>MongrelDB Kit is the right abstraction.</strong> Cross-language schema, migrations, query builder, triggers, async variants, type generation. That&rsquo;s how you build a real ecosystem, not just a core and &ldquo;good luck.&rdquo;</li>
<li><strong>The name is honest.</strong> A mongrel is a mixed-breed dog. MongrelDB is a mixed-architecture database. They named it for what it is, and that earns points in a category full of overpromising.</li>
</ul>
<h2 id="the-cons-honest-tradeoffs">The Cons (honest tradeoffs)</h2>
<ul>
<li><strong>It&rsquo;s new.</strong> SQLite has been hammered on for 25 years in production. MongrelDB is new enough that you don&rsquo;t have a community of people who have hit the edge cases for you. Auth, replication, and CDC are real, but they&rsquo;re version 1.0 of those features. Expect rough edges.</li>
<li><strong>No network mode by default.</strong> Like SQLite, you embed it in-process. The daemon exists for multi-process access, but it&rsquo;s not what MongoDB/PostgreSQL users expect. If you need horizontal scale, this isn&rsquo;t it — single-node, period. Replication is read-scaling (followers), not write-scaling.</li>
<li><strong>No KMS integration.</strong> Page-level encryption is solid, but there&rsquo;s no AWS KMS, GCP Cloud KMS, Azure Key Vault, or HashiCorp Vault. You bring your own key (passphrase or key file) and you manage it. For regulated workloads, that&rsquo;s a checklist item you handle yourself.</li>
<li><strong>DataFusion is a moving target.</strong> Pinning to &ldquo;DataFusion 54&rdquo; is great for now. It also means the SQL surface depends on what DataFusion ships. If you want a feature DataFusion doesn&rsquo;t have, you&rsquo;re at the mercy of upstream.</li>
<li><strong>Eight indexes is also a footgun.</strong> Having every kind of index doesn&rsquo;t mean you should build all eight on a single table. The planner has to make smart choices; bloat the index set and writes pay the cost.</li>
<li><strong>PHP needs a daemon.</strong> The PHP client is pure-PHP with no C extension, but it talks to <code>mongreldb-server</code> over HTTP. If you wanted in-process PHP (like PDO/SQLite), you won&rsquo;t find it here. The NAPI addon is the in-process model; PHP doesn&rsquo;t get that path.</li>
<li><strong>The benchmark comparisons are self-published.</strong> Cross-engine benchmarks on the vendor&rsquo;s own machine, with the vendor&rsquo;s own workloads. Real production data will be different. Run your own before you commit.</li>
</ul>
<h2 id="who-should-use-it">Who should use it</h2>
<p>MongrelDB is interesting if you&rsquo;re:</p>
<ul>
<li>Building a Node.js, TypeScript, Python, or PHP app that needs a single embedded store and doesn&rsquo;t want to run a separate server.</li>
<li>Building an AI-native app where vector search, FTS, and learned-sparse retrieval are first-class features of the primary store, not bolt-ons synced from somewhere else.</li>
<li>Comfortable being on a newer engine, trading some ecosystem maturity for a tighter architectural fit.</li>
<li>Running a service-oriented architecture where each service can have its own database and you don&rsquo;t need cross-service joins at the storage layer.</li>
</ul>
<h2 id="who-should-probably-wait">Who should probably wait</h2>
<ul>
<li>You need a managed, hosted, multi-region replicated database. This isn&rsquo;t that.</li>
<li>Your application is plain CRUD on a normalized schema and SQLite is already serving you fine. SQLite is the safer default.</li>
<li>You&rsquo;re doing heavy analytical workloads over millions of rows. DuckDB is still the king there, and exporting to DuckDB via Parquet is a well-trodden path.</li>
<li>You need deep compliance certifications (SOC2, FedRAMP, HIPAA-eligible). New engines take time to get there.</li>
<li>You need a 24/7 community on Stack Overflow. SQLite&rsquo;s tag has 100k+ questions. MongrelDB&rsquo;s has, well, fewer.</li>
</ul>
<h2 id="the-verdict">The verdict</h2>
<p>MongrelDB is a serious attempt at a thing that hasn&rsquo;t really existed: a single embedded engine that handles both OLTP and AI-native retrieval, with real SQL, real encryption, real auth, and a real cross-language ecosystem. It&rsquo;s not a MongoDB killer (different category) and it&rsquo;s not a SQLite killer (different priorities). It&rsquo;s its own thing.</p>
<p>The name is honest. A mongrel is what you get when you breed the parts that work and ignore the breed standard. MongrelDB is log-structured columnar storage with MVCC, a learned-index flavor, real encryption, and a DataFusion SQL frontend — all in an embedded Rust engine. The mongrel analogy holds.</p>
<p>If you&rsquo;re building a Node.js or Python AI app and you don&rsquo;t want to stand up Qdrant + Postgres + a sync layer, look at this. If you&rsquo;re writing PHP 8.4 and you&rsquo;re tired of the SQLite-or-MySQL choice, this is worth a serious look. If you&rsquo;re running SQLite in production and everything works, you have no urgent reason to migrate — but you should know what&rsquo;s coming.</p>
<p>The bar for &ldquo;yet another database&rdquo; is high, and a lot of &ldquo;yet another databases&rdquo; fail. MongrelDB has the architecture and the benchmarks to make a case. Now it needs production years. If you&rsquo;re willing to be one of the early ones, this is one of the more interesting bets in the embedded space right now.</p>
]]></content:encoded></item></channel></rss>