The choice. Where do the writes go? To one main server that keeps every rule, or to many servers that share the load by key.

Try both under load

Move a slider and watch both sides. These numbers come from a small model of how each system behaves, not from a real test.

Slow requests () as requests a second grow
PostgreSQL (SQL)Cassandra (NoSQL)
0 ms125 ms250 ms375 ms500 ms1k51k100k
Show data table
TimePostgreSQL (SQL)Cassandra (NoSQL)
1k8.5 ms3.5 ms
3.5k8.5 ms3.6 ms
6k8.5 ms3.6 ms
8.4k8.5 ms3.7 ms
11k8.5 ms3.8 ms
13k9.7 ms3.8 ms
15k11.4 ms3.9 ms
18k15.4 ms3.9 ms
21k19.1 ms4 ms
23k23.3 ms4.1 ms
26k28.1 ms4.1 ms
28k33.5 ms4.2 ms
31k39.5 ms4.2 ms
33k46.2 ms4.3 ms
36k53.4 ms4.4 ms
38k61.2 ms4.4 ms
41k69.7 ms4.5 ms
43k78.9 ms4.5 ms
46k88.7 ms4.6 ms
48k99.1 ms4.7 ms
51k110 ms4.7 ms
53k122 ms4.8 ms
55k135 ms4.8 ms
58k148 ms4.9 ms
60k162 ms4.9 ms
63k176 ms5 ms
65k191 ms5.1 ms
68k207 ms5.1 ms
70k224 ms5.2 ms
73k241 ms5.2 ms
75k260 ms5.3 ms
78k278 ms5.4 ms
80k298 ms5.4 ms
83k318 ms5.5 ms
85k339 ms5.5 ms
88k361 ms5.6 ms
90k384 ms5.7 ms
93k407 ms5.7 ms
95k431 ms5.8 ms
98k456 ms5.8 ms
100k482 ms5.9 ms

The shaded band is where you are now: 15,000 requests a second. p99 is the time the slowest 1 in 100 requests take.

15,000
2,500
8 KB

Turn this on for money or stock, where a half-done write is not allowed.

Side by side at this load

A shorter bar is better.

Slow requests (p99)scale 0 to 20 ms
PostgreSQL (SQL)
11.4 ms
Cassandra (NoSQL)
3.9 ms

Cassandra (NoSQL) is 2.9× lower.

CPU loadscale 0 to 100%
PostgreSQL (SQL)
49%
Cassandra (NoSQL)
14%

Cassandra (NoSQL) is 3.5× lower.

Cost a monthscale 0 to $1,000
PostgreSQL (SQL)
$840
Cassandra (NoSQL)
$681

Cassandra (NoSQL) is 1.2× lower.

The numbers at this load
PostgreSQL (SQL)Cassandra (NoSQL)
Typical request (p50)4.2 ms1.3 ms
Slow request (p99)11.4 ms3.9 ms
CPU load49%14%
Cost a month$840$681
StateHealthyHealthy

What to pick at this load

PostgreSQL is enough

At 15,000 requests a second, PostgreSQL keeps up. It also gives you joins and transactions, which are hard to add later.

SQL or NoSQL database: how each one is built

SQL database (PostgreSQL, MySQL)

ApplicationApplicationPrimary, takes every writePrimarytakes every writeReplica, reads onlyReplicareads onlyReplica, reads onlyReplicareads only
  • Application — healthy
  • Primary — takes every write — healthy
  • Replica — reads only — healthy
  • Replica — reads only — healthy
  • Request/response
  • Replication link

Data lives in tables with fixed columns. A transaction changes several rows together, or none of them.

Good at

  • Money and stock stay correct, because a transaction never half-finishes.
  • One query can join many tables, such as orders with customers.
  • Most engineers and tools already speak SQL.

What it costs you

  • All writes go to one main server, so writes are hard to scale.
  • Splitting the data across servers (sharding) is hard work.
  • Changing a big table can need planned downtime.
Typical latency
1 to 10 ms with an index
Work to run it
Low to medium
Best for
Payments, orders, user accounts

NoSQL store (Cassandra, DynamoDB, MongoDB)

ApplicationApplicationNode 1, a third of the keysNode 1a third of the keysNode 2, a third of the keysNode 2a third of the keysNode 3, a third of the keysNode 3a third of the keys
  • Application — healthy
  • Node 1 — a third of the keys — healthy
  • Node 2 — a third of the keys — healthy
  • Node 3 — a third of the keys — healthy
  • Request/response

Data is stored by key, with no fixed columns. The store spreads the keys across many servers by itself.

Good at

  • Add servers to handle more writes. There is no single main server.
  • Each record can have its own fields, so the shape can change fast.
  • It stays up when a server or a network link fails.

What it costs you

  • No joins: the app must fetch records and combine them itself.
  • A read can return old data for a short time.
  • You often store the same data twice, once for each way of reading it.
Typical latency
Under 5 ms for a key lookup
Work to run it
Medium to high
Best for
Sensor data, click streams, chat messages

Point by point

PostgreSQL (SQL) is better on 3 of these 5 points, and Cassandra (NoSQL) on 2. Count the points that matter to your system, not the total.

PostgreSQL (SQL)Cassandra (NoSQL)
Writes that must stay exactA transaction can change many rows and tables together. Better hereA transaction is often limited to one record or one partition.
Growing the write loadOne main server takes the writes. Past its limit you must shard.Add a server, and the store moves some keys to it. Better here
Asking new questions of the dataJoins and indexes answer queries nobody planned for. Better hereIt is fast only for the lookups its tables were designed for.
Reading right after a writeThe main server returns the new value. A replica may lag. Better hereIt depends on settings. A read may see the old value for a moment.
A server failsA replica must be promoted, and writes wait until it is.Other servers hold copies and keep answering. Better here