mcdb

maintenance

by Glenn Strauss · since 2010 · also known as mmap constant database

Memory-mapped constant database: a faster, thread-safe, >4 GB rewrite of D. J. Bernstein's cdb.

key-valueembedded libraryopen source (copyleft)legacy

maintenance. No commits since December 2022 (v0.10); stable and usable but effectively unmaintained.

Overview

mcdb is a C library for building and reading constant (write-once, read-many) key-value files, derived from Dan Bernstein's cdb. A database is written in one pass and then mmap'd read-only, so a lookup is a hash plus one or two page touches with no locking, and the format removes cdb's 4 GB ceiling and adds thread-safe readers. The package also includes nss_mcdb, which compiles passwd, group, hosts and similar files into mcdb databases as a faster alternative to nscd. The last code change was v0.10 in late 2022; it is finished, working code with a single maintainer rather than a living project.

Strengths & trade-offs

Strengths

  • +Lookups touch only one or two mmap'd pages with no locking on the read path
  • +Supports databases larger than 4 GB, unlike the original cdb
  • +Thread-safe readers and a simple build-then-rename update model
  • +nss_mcdb serves passwd/group/hosts lookups faster than nscd

Trade-offs

  • −Immutable: any change requires rebuilding the whole file
  • −Single maintainer and no commits since 2022
  • −C API (plus a Perl binding) only; no server or network access

Great for

  • +Read-only lookup tables shipped with an application
  • +Fast NSS backends for passwd, group and hosts data
  • +Static routing or configuration maps rebuilt in batch
  • +Studying cdb-style constant hash file formats

Think twice for

  • −Data that changes frequently
  • −Multi-writer or networked access

Capabilities

Native or official first-party support · 1 of 25 tracked

✓Durable persistence
–Transactions
–Joins
–Secondary indexes
–Full-text search
–Vector search
–Geospatial
–JSON
–Change data capture
–Triggers
–Stored procedures
–Materialized views
–TTL / expiry
–Pub/Sub
–Columnar storage
–In-memory
–Compression
–Encryption at rest
–Role-based access
–Time travel
–Branching
–Online schema changes
–Streaming ingest
–Offline sync
–Runs in WebAssembly

Scale & consistency

Comfortable data size
Small · ≤ 100 GB
Horizontal scaling
None
Multi-region
No
Transactions
None
Consistency
Strong
Schema
Schemaless
Architecture
Embedded
Query languages
Key-value API

One immutable file per database; updates mean rebuilding the file and atomically renaming it into place.

Deployment

Self-hosted Vendor-managed cloud Serverless Embedded Edge Kubernetes operator

Ecosystem

apis & protocolsC API
client languagesC, Perl

Alternatives to mcdb

Compare all→
cdbKey-Value3.5

D. J. Bernstein's constant database: immutable on-disk hash tables with two-read lookups and atomic swaps.

mcdb vs cdb →
LMDBKey-Value39.7

Tiny memory-mapped B+tree with ACID transactions and lock-free readers; reached 1.0 in 2026.

mcdb vs lmdb →
bboltKey-Value11.5

etcd's maintained fork of BoltDB: a simple, pure-Go B+tree store in a single file.

mcdb vs bbolt →
RocksDBKey-Value48.2

Meta's embeddable LSM-tree key-value engine, the storage layer under dozens of databases.

mcdb vs rocksdb →
Consul KVKey-Value39.0

The key-value store built into HashiCorp Consul for service config, locks and discovery.

mcdb vs hashicorp-consul-kv →
libmdbxKey-Value4.9

Heavily reworked LMDB descendant: memory-mapped ACID B+tree with auto-growing files.

mcdb vs libmdbx →

mcdb FAQ

What is mcdb?

mcdb is a key-value database by Glenn Strauss, first released in 2010. mcdb is a C library for building and reading constant (write-once, read-many) key-value files, derived from Dan Bernstein's cdb. A database is written in one pass and then mmap'd read-only, so a lookup is a hash plus one or two page touches with no locking, and the format removes cdb's 4 GB ceiling and adds thread-safe readers. The package also includes nss_mcdb, which compiles passwd, group, hosts and similar files into mcdb databases as a faster alternative to nscd. The last code change was v0.10 in late 2022; it is finished, working code with a single maintainer rather than a living project.

Is mcdb open source?

Yes. mcdb is open source. License: GNU LGPL v2.1 or later.

Does mcdb support ACID transactions?

No. mcdb does not provide ACID transactions; its consistency model is strong.

Does mcdb scale horizontally?

mcdb does not scale horizontally; it runs on a single node, so you scale it up rather than out. It is comfortable at small scale (≤ 100 GB).

How can I run mcdb?

You can self-host it and embed it in your application.

What is mcdb best for?

mcdb is a strong fit for read-only lookup tables shipped with an application; fast NSS backends for passwd, group and hosts data; and static routing or configuration maps rebuilt in batch. Think twice for data that changes frequently.

What are the best alternatives to mcdb?

Common alternatives to mcdb include cdb, LMDB, bbolt, RocksDB and Consul KV. The right choice depends on your workload, scale and hosting; WhichDB's smart match ranks them against your requirements.

Is mcdb still maintained?

mcdb is in maintenance mode. No commits since December 2022 (v0.10); stable and usable but effectively unmaintained.

How popular is mcdb?

mcdb ranks #596 of 844 databases on the WhichDB Score (0.9/100), and #104 among key-value databases. The score combines public adoption signals such as package downloads, GitHub activity, job posts and developer discussion.