EVOPEDIA

← all systems · see it in The System

Embedded database

boundaryInside: the engine's code linked into the host program (its API, SQL compiler and virtual machine where it has them, access methods, pager, locks, journal or log) and the files it owns (the database file, its journal or WAL, shared-memory index, LMDB's lock region with its reader table and writer mutex, LSM tables). Outside: the host application and its other code, the operating system and file system, the storage devices, other processes that open the same file, the network (which it does not reach itself), and the people who build and use the applications.
nested levelA part inside a program: a library in the application's process (software L4, runtime and libraries); its files sit in mass storage reached through the operating system. A kind of database (Database), the in-process kind; some embedded engines are in turn parts of server databases (RocksDB under MySQL).
scaletechnological

From the walk

SQLite's own makers say it 'does not compete with client/server databases. SQLite competes with fopen()': it is a better way to save a file. Billions of copies exist, there are likely over a trillion SQLite databases in active use, and its makers' best guess is that it is the second most widely deployed software library after libz, perhaps the most deployed counting copies per device (src:sqlite-whentouse, src:gaffney-2022, src:sqlite-mostdeployed).

Definition. A database engine that runs as a library inside the application that uses it, with no server process, keeping its data durable in local files: 'the process that wants to access the database reads and writes directly from the database files on disk' (src:sqlite-serverless). The encyclopedia's category is wider (C-4583). Definition drawn from the encyclopedia entry (Wikipedia, CC BY-SA).

On this page: Properties 2 · Measures 33 · Open contentions 3 · Cross-scale patterns 21 · Valence partners 12 · Partners and parts 71 · Notes 3 · Layers 60 · Sources 32

Properties published scienceour proposal

Sourced fields, and our own readings.

born at1979: dbm, by Ken Thompson, released by AT&T
born precisionyear

Measures (33) published science

characteristic clock: lock hold time in SQLitea few dozen ms (upper bound, makers' statement)
characteristic clock: Berkeley DB recovery after a crash, with checkpoints1-2 s
characteristic clock: fsync calls per SQLite insert on EXT4 (Android, 2013)2 or more within 2 fsync per ms
characteristic clock: Sleepycat release cadenceabout 3 commercial releases per year (1999)
SQLite databases in active use>1e12 databases (estimate)
smartphones in active use (basis of the trillion estimate)>4.0e9 smartphones
SQLite compiled library size<750 (all features); 900 KB at -Os, 1.5 MB at -O3 in the 2022 build KiB
SQLite source sizeabout 150,000 lines of C in one file
SQLite test code per line of library code>600 lines
SQLite test code (2014)>91 million lines (with parameterized repeats)
SQLite-WAL TATP throughput (cloud server)10,000 transactions per second
SSB latency: DuckDB over SQLite3-8x (flight 1) to 30-50x (flight 2) times faster
SQLite SSB speed-up from Bloom filters (Raspberry Pi)4.2 (2.7 on the cloud server) times
SQLite WAL autocheckpoint threshold1000 (about 4 MB) pages
SQLite maximum database size281 TB (2^48 bytes)
Berkeley DB maximum database size (1999)2^48 (256 TiB, about 281 TB) bytes
website traffic SQLite is said to handle<100K (conservative); sqlite.org itself 400K-500K requests in 2015 hits per day
Berkeley DB code size (1999)about 175K of text space
LMDB object code size (2012)32 KB (Berkeley DB over 1.5 MB)
crash vulnerabilities found by ALICE (11 applications)60 static (156 dynamic); LevelDB 1.10: 10, LevelDB 1.15: 6, GDBM: 5, LMDB: 1, SQLite rollback: 1, SQLite WAL: 0 vulnerabilities
share of injected power faults causing durability violations0.05-19.15 % (7 of 8 databases)
LMDB (LightningDB) durability violations under exhaustive power faults0.05 % of injected faults
exhaustive power-fault testing of LightningDBjust under 8 h (pattern-based: under 21 min) time
share of phone write requests going to SQLite filesabout 90 % (Facebook and Twitter apps, Galaxy S3)
synchronous and random shares of phone writes70% synchronous; 75% random; 64% of 4 KB % of writes
SQLite inserts per second on a 2012 phone, before and after39 to 157 inserts per second
RocksDB write amplification, leveled compaction10-30 (tiered: 4-10; SSD's own: 1.1-3; software page writes: up to 100) bytes written per byte of data
RocksDB data held at Facebookmany hundreds PB, over 30 applications
RocksDB-level corruption rateabout 1 per 3 months per 100 PB; 40% already spread to replicas corruptions
checksum mismatches from a storage-system bug in transferabout 17 per PB transferred
RocksDB writes per transaction against InnoDB (LinkBench on MySQL)5 % of InnoDB's
Debian systems regularly using libgdbm60 % of nearly 200,000
SQLite TATP: SQLite-DELETE writesabout twice the writes of SQLite-WAL per blob update

Open contentions (3) open contention

Where sources or readings disagree. Both stay on the map.

Cross-scale patterns seen here (21) our proposal

Shapes that recur when the same kind of problem is solved at different scales, and how each shows in Embedded database. Each links to every other system that shows it.

Valence: what it trades, and with whom (12) published science

Each exchange with a neighbour, read from both sides: who gains, who pays, and what carries it.

Partners and parts published science

Built from / builds (11)

Sits inside / holds (4)

expressed by (24)

floor filled by (19)

Kinds (13)

Notes published science

Layers

The ways it takes in its world, where they meet, and how it acts back, each from L1 (where it meets the world) up.

a log-structured key-value engine (LevelDB, RocksDB): writes to a log and an in-memory table, flushed to sorted files on SSD and merged level by level

  1. L1: Flash SSDs: fast, but writes wear the cells and reads and writes are asymmetric
  2. L2: Files on the server's file system: SSTables, the write-ahead log and the manifest
  3. L3: The write path: the write-ahead log and the in-memory MemTable (a skiplist), flushed to a sorted SSTable when full
  4. L4: The LSM tree: levels of sorted files, merged by compaction (leveled, tiered or FIFO), with block checksums and Bloom filters
  5. L5: The key-value interface: get, put, scans; user-defined timestamps
  6. L6: Embedded in a host: MySQL (MyRocks), CockroachDB, MongoDB, TiDB, Flink, Kafka Streams, caches; the host does replication, load balancing and backups

the boardroom (shared floors)

  1. L3: Pager and transactions: page cache, locks, rollback journal or write-ahead log, commit, rollback, checkpoint, recovery
  2. L4: Access methods: B-trees, hash tables, copy-on-write B+trees, LSM trees, with their checksums
  3. L5: The engine: the VDBE running bytecode (SQLite) or the key-value calls
  4. L6: The host process: the library inside the application's address space, on its threads
  5. L7: The application's use of its stored state

the embedded database as its makers describe it: a library in the application's own process keeping its data in local files, from the storage medium up to the application's use (reader's view)

  1. L1: Storage: the database file (and its journal or log beside it) as sectors on disk or flash; 'ordinary disk files', written in sectors that SQLite assumes are not written atomically
  2. L2: The OS interface: the virtual file system object (SQLite), shared memory and OS locks (Berkeley DB), a read-only memory map plus write() (LMDB); reads, writes, fsync and advisory locks
  3. L3: The pager and transactions: page cache, locks (SQLite's shared, reserved, pending, exclusive; Berkeley DB's two-phase locks), the rollback journal or write-ahead log, commit, rollback, checkpoint and crash recovery
  4. L4: Access methods: SQLite's table and index B-trees; Berkeley DB's B+tree, Hash and Recno; LMDB's copy-on-write B+tree; the log-structured merge tree of LevelDB and RocksDB
  5. L5: The engine: SQLite's SQL compiler and virtual machine (VDBE) running bytecode programs; in key-value engines, the get, put, cursor and join calls
  6. L6: The host process: the library linked into the application, called as functions on the application's own threads, in its own address space
  7. L7: The application's use: local data for one application or device: an application file format, a phone's records, web browsers and operating systems themselves (every Firefox, Chrome and Safari; every Windows 10/11 installation), a directory server's entries, mail aliases, a cache of enterprise data, a data scientist's dataset

way in: A crash or power loss in the middle of a write

  1. L1: Power fails or the application or OS crashes mid-transaction; the files are left partly written, and writes the device acknowledged may be missing
  2. L2: At the next open the engine finds a hot journal or a WAL beside the file

way in: A file reached over a network file system

  1. L1: The database file sits on another machine, reached through a network file system
  2. L2: The OS presents it as a local file; its locking may be buggy and its latency high

way in: Calls from the host application: SQL statements, or keys and values

  1. L1: The request in the application's own memory: an SQL statement (SQLite) or a key and a value (dbm, Berkeley DB, LevelDB, LMDB)
  2. L2: A plain function call into the linked library
  3. L3: Tokenizer and parser (SQLite): the statement read as SQL
  4. L4: Code generator and query planner: a bytecode program for the statement (key-value engines skip this floor)

way in: Corruption from beneath: media errors, bit flips, bad transfers

  1. L1: Faults below the engine: storage media corruption, CPU and memory corruption, bugs in copying files
  2. L2: Block checksums checked when a block is read
  3. L3: File checksums when files are moved; handoff checksums on WAL writes

way in: Hostile input: malicious SQL or a database file from another security domain

  1. L1: Untrusted SQL text, or a database file that something in another security domain could have written
  2. L2: Inputs arrive through the same API and file reads, against limits the application may have lowered
  3. L3: The file checked on open (integrity_check or quick_check) and refused if bad; the DEFENSIVE flag keeps SQL from writing the file's internals
  4. L4: Statements screened as they are compiled: an authorizer callback refuses classes of action

way in: Other connections, threads and processes sharing the file, seen through their locks

  1. L1: Other users of the same file: their shared, reserved, pending or exclusive locks; in WAL mode the shared-memory index; in LMDB the reader table
  2. L2: The lock request granted or refused by the operating system's file locks: POSIX advisory locks on Unix, LockFile/LockFileEx/UnlockFile byte-range locks on Windows (LMDB: a writer mutex in shared memory)

way in: The database file's own pages read back from storage

  1. L1: Sectors of the database file on disk or flash (whatever any process last wrote there)
  2. L2: Read through the OS interface (VFS read; LMDB and read-only Berkeley DB through a memory map)

way in: The developer's choices: options, journal mode, page and cache size

  1. L1: Decisions written into the host program: which features, how much concurrency and recovery
  2. L2: Passed as compile-time options, open flags and pragmas (journal_mode; WAL autocheckpoint)

way in: The engine's own growth: WAL pages since the last checkpoint, LSM level sizes

  1. L1: Its own files growing: the WAL accumulating pages; each LSM level filling
  2. L2: Compared with thresholds: 1000 WAL pages at commit; each level's size target

way out: Backup: a consistent copy of a live database

  1. L1: A snapshot file, bit-wise identical to the source as of the start of the copy
  2. L3: The online backup API copies pages, locking the source only while reading them

way out: Checkpoint and compaction: logged changes written back, old files merged and dropped

  1. L1: Files rewritten; the WAL overwritten from its start; flushed logs and old tables deleted
  2. L3: WAL pages copied back into the database file; Berkeley DB checkpoints put committed log changes on the data disk
  3. L4: LSM compaction merges a level's tables into the next level, removing dead data

way out: Commit: changes made durable on storage

  1. L1: The bits reach the medium, if the device does not acknowledge early
  2. L2: fsync through the OS; each fsync on EXT4 commits a file-system journal transaction of its own
  3. L3: The journal (or log) is forced to stable storage before the changes are applied, or the changes are appended to the WAL

way out: Errors reported: corruption caught by a checksum, handed to the application

  1. L4: A checksum mismatch found on read or transfer
  2. L6: The application discards the corrupt replica and copies in a good one

way out: Refusal and retry: the lock not granted, a deadlock victim rolled back

  1. L2: SQLite: the write attempt fails at once with SQLITE_BUSY
  2. L3: A deadlock victim chosen and rolled back; a second writer refused while one holds the write lock
  3. L6: The caller is told and may restart

way out: Rollback: the original state put back

  1. L1: The file as it was before the transaction
  2. L2: The rolled-back pages synced before the journal is deleted, truncated or zeroed
  3. L3: Original pages restored from the journal, or uncommitted logged changes undone

way out: Rows and values handed back to the caller

  1. L1: The value is in the application's memory
  2. L5: The VDBE extracts columns and emits a result row
  3. L6: Returned in the caller's own address space (LMDB: pointers into the map, no copy)

Sources (32) published science

Database (Wikipedia, via Wikimedia Enterprise snapshot 2026-11-01)
Embedded database (Wikipedia, via Wikimedia Enterprise snapshot 2026-12-01)
SQLite developers. How to corrupt an SQLite database file (sqlite.org/howtocorrupt.html; sections read: overview, 1 file overwrite, 2.1-2.3 locking, 3.1 sync, 4.1 flash) (behind its links)
SQLite Write-Ahead Logging documentation (sections read: 1 overview, 2 how WAL works, 2.1 checkpointing, 2.2 concurrency, 2.3 performance) (behind its links)
Dong S, Kryczka A, Jin Y, Stumm M (2021) Evolution of development priorities in key-value stores serving large-scale applications: the RocksDB experience. FAST '21 (sections read: 1 Introduction, 2 Background, 3.1-3.2 optimization targets, 4 replication and backup, 5 failure handling; open USENIX copy) (behind its links)
SQLite developers. Appropriate uses for SQLite (sqlite.org/whentouse.html; read in full) (behind its links)
Olson MA, Bostic K, Seltzer M (1999) Berkeley DB. Proceedings of the FREENIX Track, 1999 USENIX Annual Technical Conference (read in full from the open USENIX copy) (behind its links)
Jeong S, Lee K, Lee S, Son S, Won Y (2013) I/O stack optimization for smartphones. USENIX ATC '13:309-320 (sections read: abstract, 1 Introduction, 3 I/O characteristics of Android apps, 4.1-4.2 journaling of journal; open USENIX copy) (behind its links)
Chu H (2012) Life after BerkeleyDB: OpenLDAP's memory-mapped database (MDB, now LMDB). LinuxCon North America 2012 paper (read in full; the maker's own account, Symas) (behind its links)
Gaffney KP, Prammer M, Brasfield L, Hipp DR, Kennedy D, Patel JM (2022) SQLite: past, present, and future. PVLDB 15(12):3535-3547. doi:10.14778/3554821.3554842 (read in full from the open VLDB copy; CC BY-NC-ND) (behind its links)
SQLite developers. Most widely deployed and used database engine (sqlite.org/mostdeployed.html, updated 2026-04-21; read in full) (behind its links)
Zheng M, Tucek J, Huang D, Qin F, Lillibridge M, Yang ES, Zhao BW, Singh S (2014) Torturing databases for fun and profit. OSDI '14:449-464 (sections read: 1 Introduction, 2.1 Fault model, 5.1-5.2 results incl. Table 1; open USENIX copy) (behind its links)
Pillai TS, Chidambaram V, Alagappan R, Al-Kiswany S, Arpaci-Dusseau AC, Arpaci-Dusseau RH (2014) All file systems are not created equal: on the complexity of crafting crash-consistent applications. OSDI '14:433-448 (sections read: 1 Introduction, 4 Application vulnerabilities 4.1-4.4, Table 3; open USENIX copy) (behind its links)
Kelly T (2021) Crashproofing the original NoSQL key-value store. ACM Queue 19(4) (Drill Bits). doi:10.1145/3487019.3487353 (read in full through the paper portal; the 16 kB text holds the whole column) (behind its links)
SQLite developers. Defense against the dark arts (sqlite.org/security.html; read in full) (behind its links)
SQLite developers. File locking and concurrency in SQLite version 3 (sqlite.org/lockingv3.html; section read: the five lock states) (behind its links)
McKusick K, Seltzer M, Olson M (2021) A conversation with Margo Seltzer and Mike Olson: the history of Berkeley DB. ACM Queue 19(5). doi:10.1145/3494834.3498582 (read in full through the paper portal) (behind its links)
SQLite developers. SQLite over a network, caveats and considerations (sqlite.org/useovernet.html; section read: introduction and the channel diagram) (behind its links)
SQLite developers. Using the SQLite online backup API (sqlite.org/backup.html; section read: 1) (behind its links)
DBM (computing) (Wikipedia, via Wikimedia Enterprise snapshot 2026-12-01) (behind its links)
LevelDB (Wikipedia, via Wikimedia Enterprise snapshot 2026-12-01) (behind its links)
Access Database Engine (Microsoft Jet) (Wikipedia, via Wikimedia Enterprise snapshot 2026-12-01) (behind its links)
SQLite (Wikipedia, via Wikimedia Enterprise snapshot 2026-12-01) (behind its links)
Lightning Memory-Mapped Database (Wikipedia, via Wikimedia Enterprise snapshot 2026-12-01) (behind its links)
Berkeley DB (Wikipedia, via Wikimedia Enterprise snapshot 2026-12-01) (behind its links)
RocksDB (Wikipedia, via Wikimedia Enterprise snapshot 2026-12-01) (behind its links)
SQLite developers. Pragma statements supported by SQLite (sqlite.org/pragma.html; section read: PRAGMA synchronous) (behind its links)
SQLite developers. SQLite release 3.12.0 on 2016-03-29 (sqlite.org/releaselog/3_12_0.html; read in full) (behind its links)
SQLite developers. Database file format (sqlite.org/fileformat2.html; sections read: 1.3.4 reserved bytes per page, 4 the rollback journal, 4.1-4.3 the WAL file format) (behind its links)
SQLite developers. Transaction (sqlite.org/lang_transaction.html; sections read: read and write transactions, DEFERRED/IMMEDIATE/EXCLUSIVE) (behind its links)
Athanassoulis M, Kester MS, Maas LM, Stoica R, Idreos S, Ailamaki A, Callaghan M (2016) Designing access methods: the RUM conjecture. EDBT 2016:461-466. doi:10.5441/002/edbt.2016.42 (sections read: 1-4, from the open OpenProceedings copy; the portal held the abstract only) (behind its links)
Luo C, Carey MJ (2019) LSM-based storage techniques: a survey. The VLDB Journal 29:393-418. doi:10.1007/s00778-019-00555-y (sections read: 1 introduction, 2 LSM-tree basics: history, merge policies; through the paper portal, full text on the shelf) (behind its links)