Engine: live

MongoDB, inside

How a document database keeps its documents: as BSON in WiredTiger B-trees, keyed by record IDs, with indexes in a form that sorts as bytes, and a journal of what came since the last checkpoint. Drop a data directory and see it, down to the bytes and back up to the documents.

Data directory viewerDrop a dbPath: collections, documents, index keys, any table's pages and cells, and the journal. Nothing is uploaded.How it is storedWiredTiger's files and pages, compression, BSON and record IDs, KeyString index keys, the catalog, checkpoints and the journal.

Start here

  1. Open the sample data directory: a music database with artists, albums and tracks.
  2. Click music.albums, then a record ID: the document, and its BSON element by element.
  3. Open the index year_-1_title_1: each key, its bytes in parts (descending years inverted), and the record ID it points to.
  4. Open journal and go to the last page: the writes after the last checkpoint, which recovery replays.

WiredTiger is a B-tree engine with copy-on-write pages, like PostgreSQL and InnoDB in keeping trees on disk, but closer to LMDB in never overwriting a page in place; the SQLite and MySQL sections show their B-trees.