NoSQL in practice: key-value, document, wide-column, time-series, graph

What each non-relational family makes cheap or hard, how to design for it from the access patterns, and when Postgres with jsonb still does the job, with every system run for real on a laptop (Redis, DynamoDB Local, MongoDB, Cassandra, Neo4j, Kuzu, PostgreSQL, DuckDB). A child page of Topic: databases. Data as of October 2026. Reading: 46 min, plus 16 in closed details.

The idea in one screen

Every non-relational family stores together, in the order wanted, what one planned question reads, so that question stays one cheap read at any scale; the price is that a question you did not plan becomes a scan, a new table or impossible. That is why Postgres stays the default until a measurement says otherwise.

Fig. 1 puts the six families side by side; in each, the part one planned question reads turns orange and streams to the app. The shapes are drawn to explain (illustrative); the numbers are this page's measurements.

  1. Six layouts. Key-value in memory, key-value partitioned, document, wide-column, time series, graph: each lays its data out around the questions it expects.
  2. Redis. A key points at a data structure in memory (a hash, a sorted set, a stream); one atomic command reads or changes it, here a rank from a sorted set.
  3. DynamoDB. The partition key is hashed to pick a partition; the items of CHAT#7 sit there together in sort-key order, so a Query returns the newest ones in one request.
  4. Document. The chat is one document read whole: its metadata and a bounded subset of messages embedded, the unbounded messages referenced as documents of their own.
  5. Wide-column. The partition key (chat 7, bucket 3) is hashed to a token on a ring of nodes, copied to three replicas, and its rows are stored sorted newest first.
  6. Time series. Data is cut into one chunk per day: the last hour reads today's chunk, and retention drops whole old chunks instead of deleting rows.
  7. Graph. Users are nodes joined by FRIEND relationships; a path query follows pointers hop by hop: the measured shortest path from user 24204 to user 24891 took 4 hops.

Each family makes one shape of question cheap by how it lays data out, and pays for every other shape

Key-value in memory

Redis 8.8, Valkey

Cheap: counters, rate limits, leaderboards, queues hit thousands of times a second; pick the data structure that answers the question (a sorted set for ranks); every command is atomic.

Hard: data must fit in memory; replication is asynchronous, so a failover lost acknowledged writes here.

Postgres still does it: a counter row with UPDATE ... SET n = n + 1, a job queue with SKIP LOCKED, at low rates.

Key-value, managed and partitioned

DynamoDB

Cheap: any planned question is one request at any scale, with no servers to run; list the access patterns first, then choose partition and sort keys (often one table for everything).

Hard: a question you did not plan becomes a scan of the whole table; one busy key is capped at 1,000 writes a second.

Postgres still does it: you are not on AWS at that scale, or your questions still change every week.

Document

MongoDB 8.0

Cheap: records whose shape varies, read and written as one unit; embed what is read together, reference what grows without bound.

Hard: a document is capped at 16 MB; appends grow the document; cross-document invariants need transactions.

Postgres still does it: almost always: a jsonb column next to normal columns (measured in section 5).

Wide-column

Cassandra 5.0, ScyllaDB

Cheap: writes beyond one machine, many regions, no single point of failure; one table per query, the partition key groups what it reads, the clustering key sorts it.

Hard: no joins, no ad hoc queries; deletes leave tombstones that later reads must skip.

Postgres still does it: while one server keeps up with the writes: the root measured 2,133 to 9,212 small write transactions a second on this laptop, depending on whether each commit is really flushed to disk.

Time series

Postgres partitions, Prometheus, TimescaleDB, ClickHouse

Cheap: appends in time order, recent time ranges, rollups, dropping whole partitions for retention.

Hard: anything that is not a time range; high cardinality (a label per user) explodes memory.

Postgres still does it: native partitioning plus a rollup table, measured in section 7.

Graph

Neo4j 2026.09, Kuzu 0.11

Cheap: questions of unknown or large depth over connected data: paths, fraud rings, patterns written in Cypher.

Hard: another system to run; a fixed one or two hops is no faster than Postgres.

Postgres still does it: fixed one or two hops: a join per hop is fast (measured in section 8).

Fig. 1 above draws the layout of each family. Systems named are the ones run for this page; their versions and licences are in one dated table in Depth.

You need: the root Topic: databases, Reading sections 1 to 6 (the chat product, indexes, transactions, the families in one card each); its Database atlas tab compares about 60 systems on licence, consistency and scaling, with sources, and is cited here as "root atlas". Consistency models and quorums in general are Distributed systems fundamentals; LSM-trees and compaction internals are Storage engines and indexes; Redis as a cache is Caching; search and vector stores are Search and vector databases; graphs as a retrieval method for LLMs (GraphRAG) are GraphRAG and structured retrieval.

Access pattern
one question the app asks: what it knows, what it wants back, how often.
Partition key
the part of a key that decides which group, and so which machine, a record lives in.
Sort key
the part of a key that orders records inside their partition (clustering columns in Cassandra).
Denormalisation
storing a fact more than once, on purpose, so each question reads one place.
Hot partition
one key that gets so much traffic it hits its partition's ceiling.
Tombstone
a delete marker in an LSM store, kept until every replica has seen it.
Cardinality
the number of distinct values (of a label, a key).

Results marked measured were recorded for this page on a laptop (an Apple M1 Pro, 16 GB) on 4 and 5 October 2026 against real servers running locally; illustrative marks drawings made to explain a shape. A laptop has no network between client and server, so absolute timings are best cases; the counts (pages, rows, items, partitions) are what carries over to production.

The five habits of a professional
  1. Write the access patterns down first: every question, with its inputs, sort order and frequency. The schema comes from that list, not from the shape of the data.
  2. Choose the partition key from the busiest question and check its spread: no key may get a large share of the traffic, and no partition may grow without bound (add a time bucket).
  3. Count what a request reads, not what it returns: a filter after a scan still reads, and pays for, every item.
  4. Know the durability and replication defaults: Redis acknowledges before the replica has the write; Cassandra flushes its commit log every 10 seconds; MongoDB reads at "local" by default.
  5. Keep Postgres as the source of truth until a measurement says otherwise, and treat every other store as a copy you can rebuild.

1. Queries first: the one idea behind every family

A relational database is designed from the data (each fact stored once: normalisation) and answers any question by joining at query time. A join needs the rows of both tables in one place, which is why it lives on one machine. The non-relational families turn the design around: you write down the access patterns first, then store the data so that each question reads one contiguous piece of storage, by giving every record a partition key (which group, and so which machine) and a sort key (its order inside the group). Data needed by two questions is often stored twice: denormalisation. The chat product's questions run through the whole page:

Access patternKnowsWantsHow often
Open a chatchat idits newest 50 messages, newest firstevery page view
Send a messagechat id, user idappend one message; move the chat to the top of the listevery message
Chat listuser idthe user's chats, most recently active firstevery page view
Log inemailthe userevery login
Rate limituser idmay this user send another request now?every request
Usageuser id, monthtokens used per daybilling page
Operationsa time rangelatency and tokens per model, per minutedashboards, every few seconds
Admina model, a dayevery message of that model that dayrarely
What it costs
Every question not on the list is a problem later: in DynamoDB or Cassandra it means a new table or index (written to on every write) and a backfill of all existing data. Relational databases are the right default precisely because they do not need this list in advance. The admin question is the typical one no partitioned store answers well: it goes to an analytics copy (the Analytics: columnar engines, DuckDB and the lakehouse child).

An index finds the rows; only storing them together makes the read one page

The first three are real EXPLAIN (ANALYZE, BUFFERS) runs on PostgreSQL 16.2; the fourth is the same rows in Apache Cassandra 5.0.9 in a table designed for this question, read with tracing on. The strip is the table's data on disk to scale: each cell is pages, lit cells were read. Measured: no index 19,347 page reads, 38 ms; index 57 page reads (49 table pages), 0.129 ms; after CLUSTER 9 page reads (1 table page), 0.043 ms.

The real plans and the Cassandra trace

2. One question, four storage layouts: "the latest 50 messages of a chat"

Opening a chat is the chat product's most frequent read. The table is the root page's 1M-message table (same generator and seed) plus 20 long-running chats holding 2% of the messages, so chat 7 has measured messages over days. Messages are appended in time order, so a long chat's rows end up scattered: they sit on different 8 KB pages out of . Predict before the steps play: with an index on (chat_id, created_at), how many table pages does Postgres read for 50 rows?

Pick a layout with the buttons on the figure; its steps:

    An index tells the database where each of chat 7's rows is, but if they are scattered it still reads one page per row: . Putting a chat's rows next to each other (CLUSTER rewrites the table in index order) makes the same 50 rows one page. That is the whole idea of a partition in a wide-column store or DynamoDB: rows one question reads together are stored together, sorted the way the question wants, and the layout is maintained on every write instead of by an occasional rewrite.

    What each step costs
    The index costs a little on every insert (Storage engines and indexes measures it) and is the right fix in Postgres. CLUSTER took seconds here but locks the table and is not maintained: new rows land at the end again, so it is a one-off, not a design. The Cassandra table answers this question and no other: "every message by message id" needs another table.
    When Postgres would still do
    Almost always, for this question: with the composite index the 50 rows came back in ms on the server. A partitioned store earns its place when the writes outgrow one machine or must survive the loss of a whole data centre, not because one read is slow. Discord described its Cassandra message store at billions of messages in January 2017 and its move to ScyllaDB at trillions in March 2023 (the system design page's Case files tab, "Trillions of messages"); section 6 shows their table.

    3. Key-value in memory: Redis

    Some questions are tiny and asked constantly: "has this user sent more than 20 requests this minute?", "what rank is this player?", "is there a job waiting?". Redis keeps every key and value in memory, and a value is one of a handful of data structures, each with its own commands. The server executes commands one at a time on a single thread, so every command is atomic: no other client's command runs halfway through it. Measured here: Redis 8.8.0 in its default configuration unless stated.

    StructureWhat it holdsCommandsReal uses in the chat product
    Stringbytes or a numberSET, GET, INCR, SET key val NX PX 30000a counter; a short lock ("only one worker summarises chat 7")
    Hashfield to value mapHSET, HGET, HINCRBYa session; one rate-limit bucket (tokens, last refill)
    Listordered sequenceLPUSH, BRPOPa simple work queue (no acknowledgement: a crashed worker loses its job)
    Setunique membersSADD, SISMEMBERwho is online in a shared chat
    Sorted setunique members, each with a score, kept in score orderZADD, ZINCRBY, ZRANGE, ZREVRANKleaderboards; sliding-window rate limits; delayed jobs scored by run time
    Streaman append-only log of entries with idsXADD, XREADGROUP, XACK, XAUTOCLAIMjobs with acknowledgement and redelivery (summaries, embeddings)

    Speed is mostly the round trip: one GET took a median 52.1 µs (p99 121 µs) from Python, almost all of it client library and loopback, so one client does about 16,000 to 18,000 operations a second and 50 clients that pipeline 16 commands per round trip (send many, then read all replies) over 520,000. In production the network dominates (Jeff Dean's classic figure is 0.5 ms for a round trip inside one data centre, and Microsoft aims for under about 2 ms between availability zones: the system design page's Numbers to know tab), so the habit that matters is fewer round trips: pipelines, multi-key commands and scripts.

    Throughput measured with redis-benchmark, and what else Redis 8 ships (depth)

    50 clients with one request in flight each did about 33,000 to 35,000 operations a second (redis-benchmark, the tool that ships with Redis). Redis 8 also ships JSON documents, vector sets, time series and a query engine in the main server; HyperLogLog (approximate counts of unique items), bitmaps and geo indexes have existed for years. Each is a reason to keep more state in a store whose durability is weaker than your database's (below).

    A leaderboard: a sorted set against a count in SQL

    A sorted set is a hash table (member to score) plus a skip list, a sorted linked list with "express lane" links, so a member's position takes about log2(N) steps (Redis sorted sets: "most sorted set operations are O(log(n))"). In Postgres a rank is a count of the players above you, and the index visits one entry per player above. Measured with 100,000 players:

    When Postgres would still do
    Top-N lists are an index read in Postgres. Exact ranks for everyone on every page view are what the sorted set is for; with a few thousand players, or ranks shown as "top 5%", Postgres (or a rank recomputed every minute) is fine.

    A rank in SQL costs more the lower the player stands; in a sorted set it costs the same everywhere

    measured Postgres 16.2, index on (score DESC), SELECT count(*) FROM scores WHERE score > (SELECT score FROM scores WHERE user_id = $1): rank 3 took 6 page reads, rank 50,000 took 142 page reads, 4.67 ms; rank 95,359 took 266 page reads, 8.98 ms (server time). Redis ZREVRANK: median 91 µs wherever the player stands, from the client, so it includes the round trip. The top 10 is cheap in both: 3 page reads, 0.059 ms in Postgres, median 99 µs for ZRANGE lb 0 9 REV WITHSCORES. The set holds 100,000 members in 8.9 MB (about 93 bytes each, MEMORY USAGE) and takes score updates (ZINCRBY) at about 10,500 a second from one client.

    Rate limiting, and why it needs atomicity

    A rate limiter decides, on every request, whether a user may make another one. The obvious code reads the remaining allowance, decides in the application and writes back; run by many servers at once, two requests read the same allowance before either writes, and both pass. Predict: 16 processes each make 50 attempts against an allowance of 20; how many get through?

    The script is a token bucket: up to capacity tokens, refilled at a steady rate, one taken per request, so bursts up to the capacity and a long-run average equal to the refill rate. It uses the server's clock (TIME) so every app server agrees on "now", and passes the bucket's name in KEYS, which Redis Cluster needs to route the script to the server that owns the key. Choosing among limiter algorithms and where limits sit in a system is Reliability engineering's and Capacity planning and performance's.

    The script verbatim, and three limiter algorithms measured on Redis (depth)
    
    
    AlgorithmRedis implementationMeasured, one clientBehaviour
    Fixed windowINCR user:7:<minute> plus EXPIRE7,623 checks/scheapest; a burst at the end of one minute and the start of the next can pass twice the limit
    Sliding window loga sorted set of request times: trim older than 60 s, add, count (in MULTI)4,645 checks/sexact; one entry per request, so memory grows with the limit
    Token bucketthe Lua script above, one hash per user8,155 checks/s (21,147 with 8 clients)smooth; bursts up to the capacity; two numbers per user

    All three are round-trip bound on this laptop (one check per round trip).

    Read, decide, write lets nine times the limit through; one atomic script lets exactly the limit through

    "Read, decide, write" in the application let 188 of 800 attempts through a limit of 20. The same limit as one Lua script inside Redis let exactly 20 through, because "while executing the script, all server activities are blocked during its entire runtime" (Redis docs, scripting with Lua).

    Durability: what survives a crash

    Redis writes to disk in two optional ways (Redis persistence). An RDB snapshot is a point-in-time copy written by a forked child every so often ("you should be prepared to lose the latest minutes of data"). The append-only file (AOF) logs every write; with appendfsync everysec, the default when AOF is on, it is flushed once a second, so a power cut loses about a second of writes; with always it is flushed before each reply. Measured (SET throughput from redis-benchmark, then a writer incrementing a counter for 3 seconds before kill -9):

    RDB only: 40,255 acknowledged, all lost (no snapshot had been taken yet); AOF everysec: 50,324 acknowledged, 0 lost. A kill -9 is a process crash, not a power cut: the operating system still holds what Redis wrote, which is why AOF lost nothing. On macOS a flush does not force the drive's own cache, so always is cheaper here than on a Linux server with a real flush.

    Replication: acknowledged writes that vanish

    Redis copies writes to its replicas after replying to the client: replication is asynchronous. Fig. 2 replays the measured run: a primary and a replica on this laptop, the replica paused (as a long garbage-collection pause or a network problem would), 10 KB writes, the primary killed, the replica promoted.

    1. In sync. 1,000 writes of 10 KB acknowledged; every one reached the replica, and WAIT returned 1.
    2. The replica stalls. It is paused, as a long garbage-collection pause or a network problem would stop it. The primary does not know or care.
    3. The primary keeps saying OK. 5,000 more writes, each acknowledged to the client before it is copied; WAIT 1 500 returned 0: no replica confirmed, and asking does not make the writes safer.
    4. The primary dies. kill -9 on the primary: its memory, holding every acknowledged write, is gone.
    5. The replica is promoted. It resumes and becomes the primary with only 53 of the 5,000 acknowledged writes: 4,947 are lost although every client was told OK.

    The WAIT 1 500 call after the writes returned 0: it reports how many replicas confirmed, it does not make the writes safe ("WAIT does not make Redis a strongly consistent store", Redis WAIT). Jepsen measured the same with Sentinel failover in 2013 (56% of acknowledged writes lost; root atlas). So Redis must not be the only copy of anything you cannot rebuild.

    Streams: a job queue that survives a crashed worker

    A list makes a queue, but a worker that pops a job and crashes loses it. A stream is an append-only log; a consumer group hands each entry to one consumer and keeps it in a pending entries list until the consumer acknowledges it with XACK; another worker can claim an idle pending entry with XAUTOCLAIM. That is at-least-once delivery: a job can run twice, so it must be safe to repeat. Durable logs, the outbox pattern and Kafka are Queues, streams and async work's; a Redis stream is the small version, with Redis's durability.

    The measured stream run with real ids (depth)
      What it costs
      Memory: everything lives in RAM, plus overhead per key (93 bytes per sorted-set member above). One thread executes commands, so a slow command (a KEYS *, a long script, a ZRANGE returning a million members) stalls every client. Durability and replication are weaker than a database's by default, as measured. Redis Cluster shards keys over 16,384 hash slots, and a multi-key command or script works only when all its keys are in one slot (use hash tags such as {user:7}:bucket). The licence changed in 2024 and Valkey forked (dated table in Depth); Valkey speaks the same protocol and commands as Redis 7.2, so the code here works on both.
      When Postgres would still do
      A counter updated a few times a second (UPDATE ... SET n = n + 1 is atomic); a job queue with SELECT ... FOR UPDATE SKIP LOCKED (measured on Transactions and concurrency); a rate limit at tens of requests a second; top-N lists. Redis as a cache in front of Postgres (cache-aside, eviction, invalidation, stampedes) is Caching's subject.

      4. Key-value at any scale: DynamoDB and single-table design

      Suppose the chat product needs a store that grows without limit, survives the loss of a data centre, has no servers, upgrades or vacuum to manage, and every request already knows its key. That is what Amazon DynamoDB sells: a managed, partitioned key-value and document store, billed per request or per reserved capacity.

      The model

      • A table holds items (a map of attributes, at most 400 KB each). Each item has a primary key: a partition key, optionally with a sort key. Items with the same partition key form an item collection, stored together and sorted by sort key.
      • DynamoDB hashes the partition key to pick a partition; each partition is a Multi-Paxos group of three replicas, each with a write-ahead log and a B-tree (root atlas; Elhemali et al., Amazon DynamoDB, USENIX ATC 2022). Partitions split automatically as data and traffic grow.
      • Reads: GetItem (the full key: one item), Query (one partition key, optionally a sort key condition such as begins_with or between; items in sort order, up to 1 MB per page) and Scan (every item in the table). Nothing else: no joins, no query on a non-key attribute without an index.
      • Reads are eventually consistent by default; a strongly consistent read costs twice as much and is not available on global secondary indexes. Single-item writes are atomic; transactions cover up to 100 items in one Region and cost double (root atlas, claim corrected).
      • One read unit is a strongly consistent read of up to 4 KB (eventually consistent: half a unit); one write unit is a write of up to 1 KB. Each partition serves at most 3,000 read units and 1,000 write units a second (AWS, partition key design).

      Single-table design on the chat product

      With no joins, a screen that needs a user, their chats and a chat's messages would take several requests if each kind of item had its own table. Single-table design puts every kind of item in one table, with generic key strings (PK, SK) holding a type prefix and an id, chosen so that the items one screen needs share a partition key and come back in one Query, sorted (Alex DeBrie, The What, Why, and When of Single-Table Design, 2020-02-05). From the access patterns of section 1:

      1. Open a chat: messages get PK = CHAT#<chatId>, SK = MSG#<createdAt>#<messageId> (an ISO timestamp sorts correctly as a string; the id breaks ties). Query PK = CHAT#7, SK begins_with MSG#, descending, limit 50.
      2. Usage per day: PK = USER#<userId>, SK = USAGE#<day>, updated with an atomic ADD; Query SK begins_with USAGE#2025-09. The profile (SK = PROFILE) shares the partition, so one Query can fetch both.
      3. Chat list, most recently active first: chats sit under PK = USER#<userId>, SK = CHAT#<chatId>, sorted by id; a global secondary index (GSI1) re-keys them: GSI1PK = USER#<userId>, GSI1SK = LAST#<lastMessageAt>#<chatId>. Sending a message updates GSI1SK, and the chat moves to the top.
      4. Log in by email, emails unique: a lookup item PK = EMAIL#<email> holds the user id; registration writes the user and the lookup item in one transaction, each with attribute_not_exists(PK), so a duplicate email fails.
      5. Admin, every message of one model on one day: no key serves it without a partition that takes a quarter of all writes; it goes to an analytics copy (DynamoDB exports a table to S3 in full or incrementally, every 15 minutes to 24 hours, AWS quotas).

      Try it: start from Relational habit (one kind of item per table, keyed by its own id) and predict how many questions become scans; then switch to Single-table design. Change only the message key to MSG#{messageId} and watch "latest 50 messages" collapse into a scan.

      Every planned question is one request that reads only the items it returns. The wrong ways show what a missing key costs: a Scan with a filter for chat 7 read 1,000 items in its first page and returned none of them (the filter runs after the read, and you pay for every item read), and answering the admin question by scanning read all 54,775 items in 9 pages of 1 MB for 1,111.5 read units. At a billion items the same scan reads a billion items.

      The keys decide which questions are one request and which read the whole table

      one request, reads only what it returnsone request on an index (eventually consistent)works, but reads more than it returns or needs several requestsscan of the whole table

      Access patterns (what the app asks)

      Key design (how each item is keyed)

      The table as DynamoDB stores it: a sample of items under the current design, grouped by partition key and sorted by sort key, the way a Query sees them; rows the selected question reads are highlighted. Rules are DynamoDB's own, checked on DynamoDB Local; item counts use the measured load: .

      Every access pattern measured on DynamoDB Local, the table definition and the errors (depth)

      Measured on DynamoDB Local 3.3.1 (AWS's downloadable version of the API) with the chat data: 400 users, 2,999 chats, 49,517 messages, 54,775 items in all. Local runs the real API, key rules and capacity accounting, but not the service's partitions, throughput limits or latency, so only counts are shown.

      Secondary indexes are copies, updated later

      A global secondary index is a second copy of chosen attributes under a different key, maintained by DynamoDB asynchronously ("eventually consistent fashion ... within a fraction of a second, under normal conditions", AWS, GSI): a chat list read right after sending a message can still show the old order, and a strongly consistent read on it is refused. Each index is paid on every write: changing an indexed key costs two index writes (delete the old entry, put the new one), and an index short of write capacity throttles writes to the table.

      Index limits, writes, conditions and transactions, measured (depth)

      A table has at most 20 GSIs by default and 5 local secondary indexes (same partition key, different sort key, strongly consistent, but they cap an item collection at 10 GB and stop adaptive capacity from splitting it).

      Measured: one message put cost 1 write unit (a message item is about 173 bytes as DynamoDB counts size); the transaction that writes the message and moves the chat to the top of GSI1 cost 8 write units as DynamoDB Local accounted it. Registering a second account with an existing email failed with TransactionCanceledException, reasons [None, ConditionalCheckFailed]: the user item would have been fine, the email item already existed, so neither was written. An item over 400 KB was refused; a long document or file goes to S3 with its key stored in the item.

      Unconfirmed: 8 write units against the documented 6
      The documented rules give 6 (2 for each of the two transactional writes, 2 for moving the index entry), so Local appears to charge the index move at the transactional rate as well; unconfirmed against the real service.

      Hot partitions: the limit is per key, not per table

      All of one chat's messages share a partition key, so one very busy group chat can take at most 1,000 one-KB writes a second. DynamoDB keeps up to 300 seconds of unused capacity for bursts, and adaptive capacity moves busy items onto partitions of their own, "provided that traffic does not exceed ... the partition maximum capacity" (AWS, burst and adaptive capacity). Past that the fix is write sharding: spread one hot key over CHAT#7#0 to CHAT#7#9 and have readers query all ten and merge. Move the write rate past 1,000, then add shards:

      Two billing modes: on-demand per request (simplest, right for spiky or unknown traffic) and provisioned reserved units per hour with auto scaling (cheaper for steady, predictable traffic); dated prices are in the calculator note above and the table in Depth. Discord hit the same per-key wall in Cassandra with its busiest channels (section 6).

      One busy chat crosses the 1,000 writes a second ceiling; shards divide the load and multiply the reads

      How the monthly costs are computed, with the dated prices

      Single table or several?
      DeBrie lists the costs of single-table design: a steep learning curve, new access patterns that need data migrations, and exports for analytics that are hard to read ("looks more like machine code than a simple spreadsheet", quoted there); he advises against it for early-stage applications that still need flexibility and for GraphQL back ends, whose resolvers issue separate requests anyway. AWS's own guidance makes the same trade (AWS Compute Blog, 2021-07-26). GSIs can now use up to four attributes each for the partition and sort keys, so an index no longer needs a hand-built composite string (DynamoDB Local added it in January 2026).
      What it costs
      The schema is the list of access patterns: a new question means a new index (written on every write) or a migration. Ad hoc questions, joins and aggregates belong elsewhere (export to S3, then DuckDB, Athena or a warehouse). Indexes are eventually consistent. A busy key is capped. And it runs only on AWS (DynamoDB Local is for development).
      When Postgres would still do
      Whenever one Postgres server (with replicas for reads) can carry the load and the team would rather keep SQL's flexibility: that covers most products for years. DynamoDB wins when you are on AWS, want no database to operate, and traffic is either huge and key-shaped or tiny and spiky (on-demand costs near zero when idle).

      5. Documents: MongoDB, and Postgres jsonb beside it

      Some records have no fixed shape: a tool call carries different arguments per tool; a user's settings grow a field every month. A document stores the record as one nested JSON-like value, read and written as a unit. MongoDB keeps documents in collections, in BSON (binary JSON with real dates and integers), each with a unique _id; any field can be indexed, including fields inside arrays; queries use a JSON query language or an aggregation pipeline of stages. Underneath, WiredTiger keeps compressed B-trees and a journal; a replica set has one primary and copies; sharding splits a collection by a shard key you choose (root atlas). Measured here: MongoDB 8.0.23 as a one-member replica set, because transactions need one.

      Embed or reference? Worked on chats and messages

      MongoDB's guidance: embed when you "query pieces of information together" and update them together; reference when "the child side of the relationship has high cardinality" or "your embedded data grows without bounds" (MongoDB, embedding vs references). A chat's messages are the textbook hard case: always read together, and growing without bound. Both shapes were loaded with the same 1M messages. Predict: which shape reads fewer bytes to show chat 7's newest 50?

      Then the hard limit: a BSON document may not exceed 16 MiB (MongoDB limits). Pushing messages of about 1 KB into one chat, the th fit (the document reached bytes) and the next failed with Resulting document after update is larger than 16777216 (error 10334): the limit was hit at 15,220 messages. Appends also slow as the array grows: a $push took 6.2 ms into a 10-message chat and 13.1 ms into a 20,000-message chat of 3.4 MB, against 6.0 ms to insert one referenced message. A busy group chat would hit it in weeks, and long before that every read drags the whole history along.

      The design pros use: the chat document holds its metadata and perhaps the last few messages for the chat list (embedding a bounded subset); messages are referenced, one document each or grouped in fixed-size "buckets" of, say, 100 per document (MongoDB's bucket pattern). Tool-call arguments, whose shape varies and which are always read with their message, are embedded in the message. Every write here took several milliseconds because the default write concern (w: "majority", measured: ) waits for the journal to be flushed before acknowledging.

      Embedding reads the whole history to show 50 messages, and the document grows toward a hard 16 MB wall

      measured MongoDB 8.0.23. Referenced: 50 index keys and 50 documents of about 188 bytes, median ms. Embedded: 1 document examined, but it is KB holding all messages, median ms. Bars are drawn to one scale per row; the lower row is the document-size limit (16 MiB) with real documents marked.

      Both shapes in numbers: sizes, the read and the append (depth)

      Referenced: one document per message

      { _id: 412345, chat_id: 7, role: "user", model: "large",
        tokens: 42, content: "...", created_at: ISODate(...) }
      index: { chat_id: 1, created_at: -1 }
      • documents, average bytes; MB on disk after compression, index MB
      • send a message: insert one small document, median ms

      Embedded: one document per chat

      { _id: 7, title: "Chat 7",
        messages: [ { id: ..., role: "user", ... }, ... ] }
      read: find({_id: 7}, {messages: {$slice: -50}})
      • documents, average bytes; MB on disk
      • send a message: $push into the array: ms into a 10-message chat, ms into chat 7, ms into a 20,000-message chat ( MB)
      Indexes (the ESR rule) and the aggregation pipeline, measured (depth)

      Indexes are B-trees on one or more fields, used for equality, ranges and sorts. For compound indexes MongoDB's rule of thumb is ESR: equality fields first, then sort fields, then range fields (MongoDB, the ESR guideline); {chat_id: 1, created_at: -1} is equality then sort. An index on an array field indexes every element (a multikey index). Tokens per model per day over all 1M messages:

      
      

      It took ms and returned groups; the same question in Postgres took ms on plain columns and ms on jsonb documents. Neither is the tool for analytics at scale (section 7 and the analytics child page).

      Transactions abort on conflict; "schemaless" is optional

      A write to one document is atomic; multi-document transactions run with snapshot isolation (since 4.0 on replica sets, 4.2 on sharded clusters), at most 60 seconds by default (root atlas; MongoDB limits). Measured: two transactions updating user 7's document at once: the second failed immediately with WriteConflict (code ), labelled . MongoDB does not make the second writer wait as Postgres does; it aborts it and expects the client to retry the whole transaction, which the drivers' with_transaction helper does for that label. A collection can carry a $jsonSchema validator: one requiring chat_id and role in user, assistant or tool refused {role: "admin"} with . Without one, "no schema" becomes several schemas that every reader must handle.

      The committed transfer, and the read-concern caveat (depth)

      Moving one credit from user 7 to user 12 in a transaction committed ( and credits). Reads use read concern "" by default, which can return data that a failover later rolls back, and Jepsen found in 2020 (4.2.6) that transactions did not give snapshot isolation at the default settings (root atlas). The docs advise modelling so that most operations touch one document.

      The same documents in Postgres

      jsonb is a binary JSON column type you can index and query next to ordinary columns, inside ordinary transactions. Measured on PostgreSQL 16.2 with the same messages three ways: plain columns, one jsonb document per message, one jsonb document per chat holding its messages array.

      The jsonb-per-message table is times the size of the plain columns, because every row repeats its field names; a GIN index (an index of every key and value inside each document) answered a containment query (doc @> '{"model": "large", "role": "user", "tokens": 42}') in ms for matches, with a MB index. Appending to the jsonb-per-chat document rewrites the whole value, which the write-ahead log makes visible: bytes of log per message appended to chat 7's document against for a 10-message chat (averages over 200 appends). Inserting a message as its own row took ms whatever the chat's size.

      What it costs
      Documents move schema checks from the database into every reader; relationships across documents become application code or $lookup stages; growing arrays hit the 16 MB limit and make every write handle more; multi-document invariants need transactions that abort on conflict and must be retried.
      When Postgres would still do
      Nearly always. Keep the columns you filter, join and aggregate on as columns, and put the genuinely variable part (tool arguments, settings, raw provider responses) in a jsonb column, with a GIN or expression index if you query inside it. MongoDB earns its place when most data really is document-shaped, read and written whole, and the team wants its built-in sharding or Atlas's managed service.

      6. Wide-column: Cassandra and ScyllaDB

      Suppose messages arrive faster than one primary can write them, users are on several continents, and losing a whole data centre must not stop anyone sending. A single-primary database cannot give all three. Apache Cassandra (and ScyllaDB, its C++ reimplementation) spreads every table over many equal machines, with no primary at all.

      • A table's PRIMARY KEY ((a, b), c, d) has two parts. The partition key (a, b) is hashed to a token; the nodes form a ring in which each owns ranges of tokens, so the token decides which nodes hold the partition. The clustering columns c, d sort the rows inside it.
      • Each partition is copied to RF nodes (the replication factor, usually 3, in different racks or data centres). Every node accepts reads and writes for any key and forwards them to the replicas: there is no leader (root atlas).
      • Storage is an LSM-tree: a commit log and an in-memory table, flushed to immutable sorted files (SSTables) that background compaction merges (Storage engines and indexes owns how LSM-trees work).
      • CQL looks like SQL but has no joins, and a query must name the partition key: "data is modeled around specific queries", one table per query, data duplicated across tables on purpose (Cassandra data modelling).

      Designing the "latest 50" table

      The table measured in section 2, as created on Cassandra :

      
      

      Why bucket? A partition that grows forever lives on the same few nodes, and reading, repairing or compacting it gets slower; the modelling guide says to keep partitions "below 100,000" values and "below 100MB". Discord's January 2017 design is exactly this table: ((channel_id, bucket), message_id) with "about 10 days of messages within a bucket" (Discord, How Discord Stores Billions of Messages). Here the bucket is a 10-day window too: chat 7's messages fall into partitions, the newest holding rows. Opening the chat reads the newest bucket, and the one before if it holds fewer than 50. Any other question is refused rather than run slowly: asking for one message by id returned (ALLOW FILTERING forces it through by scanning, on a real cluster every node).

      The write path and tunable consistency

      Each request chooses how many of the RF replicas must answer: ONE, QUORUM (a majority: floor(RF/2) + 1), LOCAL_QUORUM (a majority inside the local data centre) or ALL (Cassandra, Dynamo architecture). Fig. 3 steps one write at QUORUM with one replica down:

      1. The client sends one write to any node. An INSERT of a message into partition (7, 3). Whichever node receives it becomes the coordinator for this request; there is no primary to find.
      2. Hash the partition key. The coordinator hashes (7, 3) to a token; the ring says replicas A, B and C own it. C is down.
      3. Each live replica logs, then buffers. A and B append the write to their commit log and insert it into their memtable (sorted, in memory). The default commitlog_sync: periodic flushes the log every 10 seconds, so the write is not yet on disk on either node.
      4. Two of three is a QUORUM: reply OK. RF = 3, so QUORUM = floor(3/2) + 1 = 2. A and B answered, the coordinator replies OK. At ONE it would reply after the first answer; at ALL this write would fail, because C is down.
      5. C gets a hint, not a failure. The coordinator stores a hint for C on its own disk and replays it when C comes back, if that is within max_hint_window (3 hours by default). After longer, C stays out of sync until read repair or a full repair copies the write.
      6. Later: flush and compaction. Each memtable is flushed to an immutable SSTable and compaction merges files in the background (Storage engines and indexes owns how). A read at QUORUM asks two replicas and keeps the newest timestamp.

      illustrative layout, RF = 3. Sources: the Dynamo architecture page above; commit log defaults from cassandra.yaml as measured here (commitlog_sync: , period ); hints from Cassandra 5.0, hints (max_hint_window "defaults to 3 h").

      If the replicas a write waited for (W) and the replicas a read asks (R) must overlap, W + R > RF, every read meets at least one replica with the latest acknowledged write. The default level is ONE, so by default a read can be stale (root atlas). Predict, then try: at RF 3 with one replica down, do QUORUM writes and reads still succeed and agree? Knock out a second.

      What the arithmetic does not say: conflicting writes are resolved by timestamp, last write wins, so two clients updating the same cell lose one update silently (Jepsen showed acknowledged writes lost this way in 2013; root atlas). The theory of quorums and consistency models is Distributed systems fundamentals's.

      W + R > RF guarantees overlap; each node down eats into how many failures a level survives

      Compare-and-set and multi-partition transactions (depth)

      For compare-and-set ("insert only if absent") Cassandra has lightweight transactions, which run a Paxos consensus round among the replicas for each operation and so cost extra round trips. Multi-partition ACID transactions (Accord) arrive only with Cassandra 6.0, still in alpha (root atlas). Durability: the default periodic commit log acknowledges writes before they are flushed, so one node can lose up to 10 seconds of writes in a power cut; replicas on other machines are what make the write safe.

      Tombstones: why deleting slows reads

      An LSM-tree cannot erase a row in place: the row may sit in several immutable files on several replicas. So a delete writes a tombstone, a marker that hides older data, kept for gc_grace_seconds (default 864,000 seconds, 10 days) so every replica learns of it; a replica that misses the delete for longer can bring the data back ("zombie" rows) (Cassandra, tombstones). Until compaction drops them, a read steps over every tombstone in its way. Measured: a partition of 130,000 messages, the newest deleted one by one, then "the latest 50":

      measured: 5,000 tombstones made the read about nine times slower; 101,000 made it fail, past the default tombstone_warn_threshold: and tombstone_failure_threshold: .

      Discord hit this six months into production: a public channel with millions of deleted messages and one remaining message made Cassandra "scan millions of message tombstones", causing 10-second garbage-collection pauses; they cut the grace period from 10 days to 2 and stopped re-reading empty buckets (same Discord post). The lesson: a table used like a queue (insert, read, delete) is the classic anti-pattern; expire data with a TTL in time-ordered tables, and choose compaction to match.

      Compaction strategies, and ScyllaDB, Bigtable and HBase (depth)
      StrategyHow it mergesFits
      SizeTiered (STCS)merges files of similar size once there are several (here min_threshold 4, max_threshold 32)write-heavy tables; the default, and what this table got ()
      Leveled (LCS)keeps levels of non-overlapping files, so a read touches about one file per level"read heavy workloads, or workloads with lots of updates and deletes"
      TimeWindow (TWCS)one bucket of files per time window, never merged across windows; a whole window is dropped when its TTL expires"TTL'ed, mostly immutable time-series data"
      Unified (UCS, new in 5.0)one tunable strategy that can behave like tiered or levelled"recommended for new workloads"

      Quotes from Cassandra 5.0, compaction overview.

      ScyllaDB reimplements Cassandra in C++ with one shard per CPU core and no garbage collector, speaks CQL (and a DynamoDB-compatible API), and is what Discord moved to: 177 Cassandra nodes became 72 ScyllaDB nodes (the system design page's Case files, "Trillions of messages", March 2023). Its licence terms are in the dated table in Depth. Google Bigtable and HBase share the wide-column shape (row key to column families), with single-row atomicity and no multi-row transactions.

      What it costs
      One table per question, written in step by your code; no joins; no ad hoc queries; deletes that slow reads for 10 days; last-write-wins conflicts; repairs and compaction to operate, on many machines.
      When Postgres would still do
      Until write volume, or the need to survive a data-centre loss with no failover pause, exceeds what one primary (plus replicas, plus partitioning by time) can do. Most products never get there; Discord did at billions of messages.

      7. Time series: metrics, events and what makes them special

      The operations dashboard wants requests per minute, median latency and tokens per model for the last hour, refreshed every few seconds, and a 30-day trend; every chat request produces one measurement. That data is append-only in time order, read by time range, and matters less as it ages: last hour in full, last month per minute (downsampling), then deleted (retention). Every time-series database exploits the same three facts: time-sliced chunks so a range touches few chunks, precomputed rollups, and expiry by dropping whole chunks instead of deleting rows. All three exist in plain Postgres, which is what was measured (5,184,000 request rows over 30 days: 4 models, 8 servers, about 2 a second).

      Chunks by time turn a range into a few chunks, a chart into a rollup, and retention into a drop; Fig. 4 runs the three questions on the same rows in two layouts:

      1. Two layouts, same rows. 5,184,000 request rows stored as one big table (pages in arrival order, 317 MB) and as 30 daily partitions.
      2. The last hour. The partitioned table reads only today's partition: 81 page reads, 2.48 ms. The big table's B-tree on ts is just as quick here (79 pages, 2.6 ms); partitions pay off for retention and for scans of a few days.
      3. A 30-day chart from raw rows. Every page of every day is read: 40,560 page reads, 1,405 ms.
      4. The same chart from a rollup. A one-minute rollup table (172,800 rows, one per minute and model, 14 MB against 317 MB raw) answers it in 1,728 page reads, 45.6 ms.
      5. Retention by DROP. Dropping the 7 oldest daily partitions is a metadata change: 0.06 s and 29,816 bytes of log.
      6. Retention by DELETE. Deleting the same rows from the big table rewrites pages and logs every row: 1.9 s and 65 MB of log, and the file keeps its size.

      measured PostgreSQL 16.2, one big table against 30 daily partitions. A one-minute rollup table of 172,800 rows drew the 30-day hourly chart in 45.6 ms instead of 1,405 ms from the raw rows, with the same answer (checked with EXCEPT). Dropping 7 daily partitions took 0.06 s and 29,816 bytes of log; a DELETE of the same rows from one table took 1.9 s and 65 MB of log, and the table stayed 317 MB on disk even after VACUUM (the space is reused, not returned).

      Because rows arrive in time order, a BRIN index (the minimum and maximum timestamp per block range) on ts is KB against MB for a B-tree. The same rows as compressed Parquet are about a tenth of the size, and DuckDB drew the 30-day chart straight from the file in ms: column stores are very good at this (Analytics owns them).

      The partitioned table's plan for "the last hour" (only one day's partition is read)

      Cardinality: the number that breaks metrics systems

      In Prometheus-style systems a series is one metric name plus one combination of label values, and every series costs memory and an index entry. "Every unique combination of key-value label pairs represents a new time series ... Do not use labels to store dimensions with high cardinality (many different label values), such as user IDs, email addresses, or other unbounded sets of values" (Prometheus naming). Series multiply. Predict what one user_id label does, then tick it:

      Per-user and per-request detail belongs in logs, traces or an events table in a column store, where a row per request is normal; metrics stay aggregate. Instrumenting in practice is Observability's.

      Series are the product of label counts: one unbounded label multiplies everything

      Series = product of the label value counts (an upper bound: only combinations that occur create series). Samples per day = series x 86,400 / scrape interval of 15 s. Disk per day uses Prometheus's "1-2 bytes per sample" (Prometheus storage; 2 used here); head memory per series is not documented as a fixed figure, so none is shown.

      The dedicated systems compared (depth; versions in the dated table)
      SystemHow it stores dataQuery languageReach for it when
      TimescaleDB (Postgres extension)Hypertables: a table split automatically into time chunks, older chunks converted to compressed columns; continuous aggregates are rollups kept up to date for youSQL, joins with your other tablestime-stamped data that must join your Postgres data; the two measured ideas above, automated. Compression and continuous aggregates are under the source-available Timescale License (root atlas)
      Prometheusits own TSDB: recent samples in memory plus a WAL, cut into immutable two-hour blocks on local disk, compacted later; default retention 15 daysPromQLservice metrics and alerting: it pulls ("scrapes") numbers from your services every few seconds. Deliberately one node; long-term storage goes to Thanos, Mimir or VictoriaMetrics (root atlas)
      InfluxDB 3Arrow in memory, DataFusion as the query engine, Parquet files on object storage; a WAL flushed every second (root atlas)SQL and InfluxQLhigh-volume sensor and app metrics with many tag values, kept cheaply on object storage
      ClickHouseMergeTree: sorted, compressed column parts merged in the background (root atlas); a table-level TTL drops old data (ClickHouse MergeTree)SQLevents, logs and metrics at billions of rows when you want SQL over everything; often does a dedicated TSDB's job

      Two corrections from the root atlas: Thanos (sidecar mode) uploads Prometheus's own blocks, while Mimir and Cortex receive samples by remote write and build the blocks themselves; and InfluxDB 3 is a Parquet and DataFusion engine, unlike the 1.x and 2.x engines most tutorials describe.

      When Postgres would still do
      Up to hundreds of millions of rows on one server with native partitioning by day, a BRIN or B-tree index on time, a rollup table refreshed by a scheduled job, and DROP of old partitions; TimescaleDB automates exactly this. Service metrics with alerting belong in Prometheus (or a hosted equivalent) regardless; analytics over billions of events in a column store.

      8. Graph: Neo4j, Kuzu, and the recursive query

      Some questions are about connections: "people you may know" (friends of friends), "is this account linked to a known fraud ring within four steps", "how is user A connected to user B". In tables each step is a join, and the number of steps is not known when you write the query. A property graph has nodes (a user, a chat) and relationships (FRIEND, OWNS), each with a type, a direction and properties. Queries are patterns in Cypher (Neo4j also accepts GQL, the ISO graph query language that grew out of it): MATCH (u:User {uid: $u})-[:FRIEND*1..3]-(v) RETURN count(DISTINCT v) reads "from user u, follow one to three FRIEND relationships in either direction". Neo4j stores each relationship as a record pointing directly at its two nodes and at the next relationship of each, so following one is a pointer lookup rather than an index search: index-free adjacency (root atlas; Robinson, Webber and Eifrem, Graph Databases, 2nd edition, O'Reilly 2015, chapter 6).

      Fig. 5 follows one of the ten sampled users, user 24204, outward on the measured graph:

      1. Within one hop: 27 friends. Each FRIEND relationship points straight at the node on its other end, so finding the friends is following 27 pointers.
      2. Within two hops: 891 users. Friends of friends: each friend's own relationships are followed, and users already seen are dropped.
      3. Within three hops: 29,933 users. About 30% of the 100,000: the few very connected users pull the frontier across the graph (area to scale on the floor).
      4. Within four hops: 99,898 users. Nearly the whole graph; every engine must touch those rows, which is why the timings converge below.
      5. The path instead of a count. Neo4j's shortestPath found user 24204 to user 24891 in 4 hops (24204, 6190, 116, 4989, 24891) in 5.0 ms.

      Measured: friends of friends, on the same graph

      A synthetic social graph grown the way real ones grow (each new user befriends 10 existing users, chosen in proportion to how many friends they already have): users, friendships, a median of friends but a most-connected user with . For 10 random users, count everyone within k hops on PostgreSQL 16.2 (two ways), Neo4j Community and Kuzu , an embedded graph engine (a library, like DuckDB). Predict which engine wins at two hops.

      All four engines agree on every count. At four hops, where every engine touches nearly the whole graph, Neo4j was only than Postgres's better query. Times are measured from the client (Neo4j and Postgres over a local connection, Kuzu in process). The work is set by the answer: by 3 hops a typical user reaches about a third of the graph, by 4 nearly all of it, and every engine must touch those rows. In SQL, write one DISTINCT join per hop to keep each frontier small; a naive recursive query (whose UNION removes only exact duplicate (user, depth) rows) finished here but revisits users along many paths on denser graphs. Neo4j's planner made the same move by itself: VarLengthExpand(Pruning,BFS,All), a breadth-first expansion that drops nodes already seen.

      For counting neighbours, the graph engines did not win: Postgres was fastest up to three hops

      The SQL and Cypher that ran, and the plans

      Where a graph database wins: paths and patterns

      Ask for the path instead of a count. Neo4j's shortestPath connected user to user in hops in ms with one line of Cypher. In Postgres:

      The SQL that carries the path is short but explores every path rather than every user, so it slows sharply with depth; the version with a visited set must be driven from application code, one query per hop. Graph databases earn their place when such questions are the product (fraud rings, recommendation paths, permissions inherited through groups, knowledge graphs), when depth is variable or large, and when patterns over several node and relationship types ("accounts that share a device with an account that shares a card with a flagged account") would be a page of SQL. Building a graph from documents for LLM retrieval is GraphRAG and structured retrieval's.

      Caveats
      Neo4j runs transactions at read committed: "a transaction that reads a node/relationship does not block another transaction from writing" it, so lost updates are possible unless a write lock is taken; Cypher takes one automatically for SET n.x = n.x + 1 (Neo4j, concurrent data access). Kuzu's repository was archived by its owners, so treat it as a demonstration, not a dependency (dated table in Depth). Apache AGE adds Cypher inside Postgres, with traversals planned as joins (root atlas).
      When Postgres would still do
      Fixed one to three hops (friends, friends of friends, a group's members' chats): one join per hop with an index on both ends, measured above. Bounded hierarchies (an org chart, folders) with a recursive CTE. Move to a graph database when variable-depth path questions are central and frequent, or the pattern queries become unmaintainable in SQL.

      Choosing: Postgres with jsonb, or another store

      Each section's measurement names the problem that justifies a second store; without one, Postgres does the job

      The measured problemPostgres firstThe store it justifies
      Exact ranks for 100,000 players on every page view cost 9 ms each (section 3)top-N from an index; ranks recomputed every minuteRedis sorted set
      Thousands of atomic checks a second (rate limits, counters)UPDATE ... SET n = n + 1; SKIP LOCKED queuesRedis, with a Lua script
      Writes exceed one primary, or must survive a data-centre loss with no failover pause (sections 4 and 6)replicas, partitioning by time, then Scaling a databaseCassandra, ScyllaDB or DynamoDB, keys from the access patterns
      Records of varying shape, read and written whole (section 5)columns plus a jsonb column, GIN indexMongoDB, when most data is document-shaped
      Every dashboard query scans 30 days (section 7)daily partitions, a rollup table, BRINPrometheus for metrics; a column store for events
      Variable-depth paths and patterns are the product (section 8)a join per hop; recursive CTE for hierarchiesNeo4j
      1. Start with Postgres as the source of truth and write down the access patterns (section 1). Most of the families' tricks exist in Postgres in smaller form: a composite index (section 2), jsonb (section 5), partitions and rollups (section 7), a join per hop (section 8), SKIP LOCKED queues.
      2. Add a store only for a measured problem, named in one sentence: "ranks for 100,000 players on every page view cost 9 ms each" (Redis); "message writes exceed one primary" (Cassandra, ScyllaDB or DynamoDB); "every dashboard query scans 30 days" (a rollup, then a time-series or column store).
      3. Treat every extra store as a copy that can be rebuilt from the source of truth, fed by an outbox or change data capture (Queues, streams and async work), with its own backups, monitoring and on-call knowledge. "Polyglot persistence" (several stores, each for what it does best) is real at scale and an expensive habit before it.

      Backups, replication and failover for Postgres itself are Running Postgres in production's; sharding Postgres and distributed SQL are Scaling a database's.

      Depth

      Settings pros check first, per system (a checklist)
      SystemSettings pros check first (each explained on this page)
      Redis / Valkeymaxmemory and an eviction policy when it is a cache, noeviction when it holds data you need; appendonly yes with appendfsync everysec if losing a minute matters; replicas plus Sentinel or Cluster for failover, knowing that failover can drop acknowledged writes; no KEYS * in production (use SCAN); short scripts.
      DynamoDBaccess patterns and keys reviewed before the first write; on-demand capacity until traffic is predictable; alarms on throttled requests; Contributor Insights to find hot keys; a TTL attribute to expire items; incremental export to S3 for analytics.
      MongoDBwrite concern majority (the default since 5.0); a $jsonSchema validator per collection; one index per access pattern, ordered by ESR; no unbounded arrays; transactions short and retried on TransientTransactionError.
      Cassandra / ScyllaDBreplication factor 3 across racks or zones, LOCAL_QUORUM for reads and writes that must agree; partitions bounded by a time bucket; repair run more often than gc_grace_seconds; alerts on tombstone warnings and large partitions; compaction chosen per table.
      Prometheus and friendsno unbounded label values; retention and rollups set on purpose; long-term storage (Thanos, Mimir, VictoriaMetrics) only when one server's retention is not enough.

      Configuration names and documented behaviours from the sources linked in each section; a checklist, not a complete production guide.

      Mistakes with a measured cost (each points back to its section)
      • Read, decide, write in the application: 188 requests passed a limit of 20. Use the store's atomic operation (INCR, a Lua script, a conditional write, UPDATE ... SET n = n - 1 WHERE n > 0).
      • Redis as the only copy: a failover lost 4,947 of 5,000 acknowledged writes here; an RDB-only server lost every write since its last snapshot.
      • A partition key that concentrates traffic: the current date, a tenant with most of the traffic, one celebrity chat. Every partition has a ceiling (1,000 writes a second in DynamoDB).
      • Partitions or documents that grow forever: a chat document hit the 16 MB limit at 15,220 messages; a Cassandra partition per chat grows without limit. Bucket by time or count.
      • Cassandra as a queue, or bulk deletes: 5,000 tombstones made a read about nine times slower; 101,000 made it fail.
      • Reading your own write from an index or replica: DynamoDB GSIs, MongoDB secondaries, Redis replicas and Cassandra at ONE can all return data from before your write. Read from the primary, or use a strong read where one exists, for the request right after a write.
      • Deleting old time-series rows with DELETE: Measured: 1.9 s and 65 MB of log for 7 days, and the table did not shrink.
      Embedded key-value engines: RocksDB and LMDB (the libraries under other systems)

      Every database above sits on a storage engine: the library that turns "put this key and value" into bytes on disk. RocksDB is an embedded LSM-tree: a write-ahead log and a memtable, sorted files, background compaction; fast writes, tunable read, write and space amplification, many knobs. It is inside CockroachDB (via Pebble, its Go port), TiKV, Kafka Streams' state stores and many others; by default its WAL is not flushed to disk on every write, so a machine crash can lose the last writes (root atlas). Storage engines and indexes measures its amplification against Postgres. LMDB is a copy-on-write B+tree in one memory-mapped file: no WAL, no compaction, readers never block and see a consistent snapshot, but one writer at a time; very fast reads from many threads or processes; commits are flushed by default.

      Reach for one directly only when building a storage component (a queue, a persistent cache, an index) inside one process and you want neither a server nor SQL. Otherwise SQLite (rows, SQL, one writer) and DuckDB (columns, analytics), on the root page, are the embedded databases to use.

      Versions, licences and prices, dated (volatile: checked 4 and 5 October 2026)
      SystemVersion used or currentLicence and dated facts
      Redis8.8.0 measuredBSD until 7.2; dual source-available licence (RSALv2 or SSPLv1) from 7.4 on 20 March 2024; Redis 8 added AGPLv3 as a third option on 1 May 2025. Redis 8-only features (built-in JSON, vector sets, the query engine) do not exist in Valkey under those names.
      Valkeyfork of Redis 7.2.4BSD, launched by the Linux Foundation on 28 March 2024, backed by AWS, Google Cloud, Oracle and others
      DynamoDBDynamoDB Local 3.3.1 measuredUS East (N. Virginia), standard table class, read 4 October 2026: on-demand $0.625 per million write units and $0.125 per million read units (on-demand pricing); provisioned $0.00065 per write unit-hour and $0.00013 per read unit-hour (provisioned pricing); storage $0.25 per GB-month
      MongoDB8.0.23 measured; 9.0 generally available 28 September 2026server under the SSPL (source-available) since 16 October 2018
      Cassandra5.0.9 measured; 6.0 in alpha (Accord transactions)Apache 2.0
      ScyllaDB2025.1 onwardAGPL open-source edition ended with 6.2; one source-available product, free only within 10 TB and 50 vCPUs (licence v1.1, April 2026)
      Neo4jCommunity 2026.09.0 measuredCommunity is GPLv3; clustering is Enterprise-only
      Kuzu0.11.3 measured (last release)GitHub repository archived by its owners on 10 October 2025; still works, receives no fixes (kuzudb/kuzu)
      Time-series systemsTimescaleDB 2.30, Prometheus 3.15, InfluxDB 3.11, ClickHouse 26.9TimescaleDB compression and continuous aggregates under the Timescale License
      Embedded enginesRocksDB 11.8; LMDB 1.0.0 released 30 June 2026 after the long 0.9 line

      From the root page's Database atlas (sources there) unless linked.

      Glossary (every term, linked to where it is explained)
      Measured on 4 and 5 October 2026 on an Apple M1 Pro laptop (16 GB, macOS) with Redis 8.8.0, MongoDB 8.0.23, OpenJDK 17 and 25 (conda-forge, installed in a scratch directory), DynamoDB Local 3.3.1, Apache Cassandra 5.0.9, Neo4j Community 2026.09.0, Kuzu 0.11.3, PostgreSQL 16.2 (pgserver wheel) and DuckDB 1.5.6. Every run is under 10 minutes; the scripts and raw outputs are in the page's src/measure and src/inputs folders. Facts about other systems come from the root page's Database atlas (checked on 4 October 2026) unless linked.