Ordered Key-Value Store
An Ordered Key-Value Store (OKVS) is a type of data storage paradigm that can support multi-model database. An OKVS is an ordered mapping of bytes to bytes. It is a more powerful paradigm than Key-Value Store because OKVS allow to build higher level abstractions without the need to do full scans. An OKVS will keep the key-value pairs sorted by the key lexicographic order. Some OKVS provide a way to customize the sorting algorithm. OKVS systems provides different set of features and performance trade-offs. Most of them are shipped as a library without network interfaces, in order to be embedded in another process. Most OKVS support ACID guarantees. Some OKVS are distributed databases. Ordered Key-Value Store found their way into many modern database systems including NewSQL database systems like Google Spanner, CockroachDB and TiDB.
The origin of Ordered Key-Value Store stems from the work of Ken Thompson on dbm in 1979. Later in 1991, Berkeley DB was released that featured a B-Tree backend that allowed the keys to stay sorted. Berkeley DB was said to be very fast and made its way into various commercial product. It was included in Python standard library until 2.7. In 2009, Tokyo Cabinet was released that was superseded by Kyoto Cabinet that support both transaction and ordered keys. In 2011, LMDB was created to replace Berkeley DB in OpenLDAP. There is also Google's LevelDB that was forked by Facebook in 2012 as RocksDB. In 2014, WiredTiger, successor of Berkeley DB was acquired by MongoDB and is as of 2019 the primary backend of MongoDB database.
Other notable implementation of the OKVS paradigm are Sophia and SQlite LSM extension. Another notable use of OKVS paradigm is the multi-model database system called ArangoDB based on RocksDB.
There are algorithms that encode basic data types (string, integer, float) and composition of those data types using containers like tuples, lists or vectors that preserve their "natural" ordering. That is, one can work with an Ordered Key-Value Store without having to fiddle with bytes directly. In FoundationDB, it is called the tuple layer.
One can construct key spaces to build higher level abstractions. The idea is to construct keys, that takes advantage of the ordered nature of the top level key space. When taking advantage of the ordered nature of the key space, one can query ranges of keys that have particular pattern.
De-normalization, as in, repeating the same piece of data in multiple subspace is common practice. It allows to create secondary representation (also called indices) that will allow to speed up queries.
Higher Level Abstractions
As of 2019, the following abstraction or databases were built on top Ordered Key-Value Stores:
- Timeseries database,
- Record Database, also known as Row store databases, they behave similarly to what is dubbed RDBMS,
- Tuple Stores, also known as Triple Store or Quad Store but also Generic Tuple Store,
- Document database, that mimics MongoDB API,
- Full-text search
- Geographic Information Systems
- Property Graph
- Versioned Data
All those abstraction can co-exist with the same OKVS database and when ACID is supported, the operations happens with the guarantees offered by the transaction system.
|OKVS||License||Transactions||Distributed||In-memory||multiple threads||multiple processus|
|SQLite LSM Extension||Public domain||Yes (nested)||No||Yes||yes (single writer)||yes (single writer)|
- "BerkeleyDB & other distributed high performance key/value databases - High Scalability -". highscalability.com. Retrieved 2020-01-16.
- "11.11. bsddb — Interface to Berkeley DB library — Python 2.7.17 documentation". docs.python.org. Retrieved 2020-01-16.
- "sophia - modern transactional key-value/row storage library". sophia.systems. Retrieved 2020-01-16.
- "LSM Key/Value Storage in SQLite3".
- "Comparing new RocksDB and MMFiles storage engines". ArangoDB. Retrieved 2020-01-16.
- "Python API — FoundationDB 6.2". apple.github.io. Retrieved 2020-01-19.
- "How FoundationDB Powers Snowflake Metadata Forward | Snowflake Blog". Snowflake. 2018-04-19. Retrieved 2020-01-17.
- A record-oriented store built on FoundationDB., FoundationDB, 2020-01-16, retrieved 2020-01-17
- "Generic Tuple Store Database". srfi.schemers.org. Retrieved 2020-01-17.
- "Generic Tuple Store".
- A document data model on FoundationDB, implementing MongoDB® wire protocol: FoundationDB/fdb-document-layer, FoundationDB, 2019-12-09, retrieved 2020-01-17
- meilisearch/MeiliSearch, MeiliSearch, 2021-06-19, retrieved 2021-06-19
- "6.1. GeoMesa Index Structure — GeoMesa 1.3.1 Manuals". www.geomesa.org. Retrieved 2020-01-19.
- "The JanusGraph FoundationDB Storage Adapter - Ted Wilmes, Expero Inc". www.youtube.com. Retrieved 2020-01-17.
- "Lightning Talk: Entity Store: A FoundationDB Layer for Versioned... - Stephen Pimentel, - YouTube". www.youtube.com. Retrieved 2020-01-17.