Which database for which problem

Software & architecture · databases · Jul 2026

The right question is never which database you like. It is what the data looks like, how it is written, how it is read, and what happens when two writers collide, and the store falls out of those answers. This page cross-references every systems-design problem on this site with the datastore that wins there and the one-line reason it wins, grouped by store family. Each row links to the full write-up, so this doubles as a map of the whole systems section.

The procedure that generates every row is the same. Name the access pattern first, meaning the exact reads and writes on the hot path, with their rates. Name the guarantee the product actually needs, atomicity across rows, per-key ordering, expiry, replay, or nothing at all. Then let the pattern and the guarantee pick the family, and only at the end pick a brand inside the family. Saying "we'll use Postgres for everything" or "we'll use MongoDB because it scales" before naming the access pattern is the classic way to get the storage decision wrong.

The one-line version. Transactions and audits go relational. High-volume writes with known access paths go wide-column. Anything disposable and hot lives in memory. Big immutable bytes go to object storage behind a CDN. Text search gets an inverted index, similarity gets a vector index, replayable history gets a log, metrics get a time-series store, and relationships walked hop by hop get adjacency lists. The data's shape and rate choose the store, and the brand comes last.

Relational, when money or invariants are on the line

A relational store earns its place when several rows must change together or not at all, when an auditor's questions map onto SQL, and when the write rate is modest enough that correctness can be the priority. Every money problem on this site lands here, and so does every problem whose core is a single authoritative decision, like the last hotel room or the last parking spot. The deep dive on internals lives in the PostgreSQL note.

ProblemWhat it stores thereWhy relational wins
Payment systemAppend-only double-entry ledger, partitioned by monthMoney must reconcile provably against the bank, and debits equal credits is a multi-row invariant
Hotel reservationPer-night inventory rows with a version columnCompare-and-set on the version stops two guests buying the last room
RideshareTrip row plus append-only trip eventsTrips are durable, auditable, and carry payments, so they get transactions while locations stay in memory
Stock brokerageOrders sharded by user idOrder state chooses consistency over availability, and per-user listing is a single-partition read
Digital walletEvent-sourced per-account log over a relational baselineOrdered, replayable money movements per account with an audit trail
Notification systemDevice tokens, preferences, and a delivery logA unique key on the delivery log doubles as the idempotency record
Parking lotTickets and spot state per garageOne conditional UPDATE decides the last spot, correctness over throughput at one request a second
Cloud file storageSharded metadata by namespaceVersion commits are atomic per namespace while the bytes live in object storage
Social graph searchAdjacency lists in sharded MySQL behind a write-through cacheOne keyed read returns a whole friend list, the TAO shape
Proximity serviceReplicated businesses table with a geohash indexThe source of truth is about 100 GB, small enough to replicate rather than shard

Wide-column and key-value, when writes are heavy and the query is known

Wide-column stores like Cassandra and managed KV like DynamoDB win when the write rate is high, the access pattern is known in advance, and every hot read is a point lookup or a single-partition range. You give up joins and ad-hoc queries and buy linear write scaling, which is exactly the trade messaging and lookup-table problems want.

ProblemWhat it stores thereWhy wide-column or KV wins
Chat systemMessages partitioned by channel idAppend-heavy writes read back as recent ranges inside one partition, no joins on the hot path
Ephemeral messagingMessages with native row TTL by conversationEvery row must expire on its own, so TTL belongs to the store, not to application code
URL shortenerCode to URL keyed by short codeA single-key point lookup on a read path a hundred times heavier than writes
Key-value storeThe Dynamo-style quorum store itselfPoint get and put at massive scale, staying writable through partitions
Distributed emailMailbox metadata partitioned by userSmall hot user-scoped rows with transactions, while bodies live in object storage by content hash
Collaborative editorOperation log partitioned by document idAppend-only edit operations replayed in server order rebuild the document

In-memory, when the data is hot and disposable

Memory is the right home for data that is overwritten in seconds, rebuilt cheaply, or read at rates no disk path can serve. The recurring move is to notice that durability buys nothing for data that expires before a restore would finish, and the Redis note covers the structures underneath these rows.

ProblemWhat lives in memoryWhy memory wins
Rate limiterToken-bucket counters with TTL, atomic via LuaSub-millisecond check-and-decrement on every request, expiry tracks only active callers
Nearby friendsLive locations under a 60 second TTL, deliberately not durablePositions overwrite every 30 seconds, and the expiring key doubles as the offline signal
Gaming leaderboardSorted sets as the rank view, rebuildable from the match logExact rank in logarithmic time from skip-list counts, treated as a view rather than the truth
Distributed cacheThe sharded cache itselfPoint lookups at hundreds of thousands of operations per second shielding the database
AutocompletePrefix to top-K tables held fully in RAMOne bounded read per keystroke under a twenty millisecond budget
Stock exchangeThe order book, one core per symbolMicrosecond price-time matching over data that fits in cache, with a sequenced log as the truth
RideshareThe driver geo index, sharded by city cell1.25 million disposable position writes per second that would crush any durable store

Object storage, when the bytes are big and immutable

Object storage wins whenever the payload is large, written once, and read by key, and it pairs with a CDN the moment readers are geographically spread. The metadata that describes the bytes always lives somewhere else, which is the two-plane split that shows up in every row here.

ProblemWhat it stores thereWhy object storage wins
Video streamingEncoded segments and manifests at the originEgress near 125 Tbps is a byte-placement problem, so cheap origin plus CDN caches carry it
Object storageThe system itself, metadata and data planes splitEleven nines of durability from erasure coding, with hot metadata scaled separately
Cloud file storageContent-addressed four megabyte blocksDedup and delta sync fall out of addressing blocks by their hash
Web crawlerRaw HTML keyed by content hashIdentical pages dedupe by construction, and the scheduler's bookkeeping stays in a database
Google MapsImmutable map tiles behind a CDNA trillion tiles fetched by zoom and coordinate key from an edge near the viewer
Street View blurringPetabytes of panoramas, originals access-controlledAn idempotent batch pipeline over an immutable corpus, re-runnable as models improve

Search indexes, when the query is words

An inverted index maps each term to the documents containing it, which turns keyword search from a corpus scan into a lookup whose cost scales with the result size. The Elasticsearch note covers segments, refresh, and why these indexes are views over a source of truth rather than the truth itself.

ProblemWhat it indexesWhy an inverted index wins
Search serviceDocuments in sharded immutable segmentsRanked keyword lookup served lock-free from segments, rebuilt behind an alias
Video searchMetadata and transcripts, next to a vector indexText wins exact and rare terms while vectors win paraphrase, so both run and the ranker merges
Distributed emailPer-user indexes that never cross accountsSearch space per query is one mailbox, so sharding by user makes every query small
Post searchPosts by term, sharded, fed from the write logBillions of tiny documents where fan-out and freshness dominate the design

Vector indexes, when the query is similarity

When the question is what is most similar rather than what matches these words, embeddings plus an approximate nearest neighbor index replace the inverted index. The trade is recall against latency and memory, which is the entire subject of my ANN benchmark project, and the vector databases note covers the index families.

ProblemWhat it indexesWhy a vector index wins
Similar listingsListing embeddings, rebuilt nightly and swapped atomicallyNearest neighbors in behavior space on every page view under a hundred milliseconds
Visual searchA billion image embeddings in sharded HNSWNearest catalog vectors to a query crop without comparing against everything
Video recommendationItem embeddings from a two-tower modelNo ranker can score billions of items per request, so retrieval must be a vector lookup
Harmful content detectionPerceptual hashes and media embeddingsRe-shared violating media is caught by index lookups before any expensive model runs
People you may knowGraph embeddings as a candidate sourceTwo-hop traversal finds structure, embeddings find similar people the graph has not connected yet

Logs and streams, when history must replay

An append-only partitioned log is the right source of truth when consumers need to replay history, when several systems must see the same events in the same order, or when an audit depends on reproducing a computation. The Kafka note covers offsets, consumer groups, and replication.

ProblemWhat the log holdsWhy a log wins
Ad click aggregationRaw clicks retained for ninety daysBilling-grade counts must be reproducible, so the log is the truth and aggregates are views
Distributed message queueThe partitioned log itselfSequential disk writes sustain a gigabyte per second, and retention makes replay free
Stock exchangeEvery inbound message, globally sequencedReplicas replaying the same ordered stream stay bit-identical, and failover promotes a correct standby
Metrics monitoringThe ingest buffer between agents and storageCollectors and the TSDB scale and fail independently
Top-K heavy hittersRaw events, replayable and archivedThe exact batch count that corrects the sketch needs the full history

Time-series and OLAP, when the axis is time

Metric workloads append millions of timestamped samples per second and read them back by recency, which random-write B-trees cannot survive. Purpose-built stores compress deltas, roll data into coarser resolutions as it ages, and index series labels separately. The time-series databases note covers Gorilla compression and retention tiers, and ClickHouse covers the columnar side.

ProblemWhat it stores thereWhy time-series or columnar wins
Metrics monitoringA million samples per second across ten million seriesDelta-of-delta and XOR compression make append-heavy, recency-read data cheap
Ad click aggregationPer ad, per minute aggregates in a columnar storeAnalysts scan a few columns over long ranges, the columnar sweet spot
Google MapsLive segment speeds keyed by edge and windowThe traffic model reads recent windows per road segment, nothing older matters

Graphs, coordination stores, and the honest none

Relationship-walking problems store adjacency lists sharded by user, so one hop is one keyed read, and social graph search, people you may know, and the social platform all take that shape rather than reaching for a dedicated graph database. Coordination stores like ZooKeeper and etcd hold tiny, precious state off the hot path, worker-id leases in the unique ID generator, ID range leases in the URL shortener, and the hash ring in the collaborative editor. And some problems need no datastore where you expect one. The Snowflake generator mints uniqueness from its bit layout with nothing in the write path, top-K counts approximately in a bounded sketch, and the interplanetary design merges state through CRDTs because no store can coordinate across a forty minute round trip. Saying "this piece needs no database, and here is why" is one of the strongest storage answers available.

The checklist to run. What are the exact hot-path reads and writes, with rates. Which writes must be atomic together. Does anything expire, replay, or need an audit. Is any single item hotter than one machine can take. What staleness can each read tolerate. Answer those five and say the family before the brand, then name one concrete pitfall of your choice, tombstones in Cassandra, hot partitions in DynamoDB, cache inconsistency in front of Postgres, and you have given the complete storage answer.

References

  1. Kleppmann, Designing Data-Intensive Applications (2017), the book behind most of these trade-offs.
  2. DeCandia et al., Dynamo: Amazon's Highly Available Key-value Store (2007).
  3. Chang et al., Bigtable: A Distributed Storage System for Structured Data (2006).
  4. Bronson et al., TAO: Facebook's Distributed Data Store for the Social Graph (2013).