class: center, middle # BoltDB vs LMDB Craig M. Brandenburg c.m.brandenburg@gmail.com --- # BoltDB and LMDB similarities * Both are **local key-value stores**—i.e., server-free, schema-free, non-relational, and typically *fast*. * Both are **memory-mapped**—i.e., small databases reside in memory but databases can be bigger than the sum of physical memory and swap space. * Both store data using a **B+tree** and provide **ACID** and **MVCC** semantics. * Both provide **shared reading** and **exclusive writing**, relying on **explicit transactions**. * BoltDB originally was a port of LMDB. --- # Terminology interlude * BoltDB has a **database** containing **buckets** containing key-value **items**. * LMDB has an **environment** containing **databases** containing key-value **items**. As an analogy: * SQL has a **database** containing **tables** containing **rows**. --- # BoltDB advantages * BoltDB is **pure Go**, which is more convenient for the typical Go programmer. * BoltDB supports **nested buckets**, making it convenient for hierarchical information. * BoltDB has a **very simple API** that is pleasant to use. --- # LMDB advantages * LMDB is generally **faster**. * LMDB provides optimization features, such as **integer keys**. * LMDB supports **duplicate keys**. * LMDB allows for multiple readers and one writer **simultaneously**—i.e., readers never get locked out. * LMDB has bindings for **many languages**: C, Go, Python, Rust, etc. --- # Project URLs **BoltDB** * https://github.com/boltdb/bolt **LMDB** * https://github.com/LMDB/lmdb (C) * https://github.com/bmatsuo/lmdb-go (Go wrapper)