NewSQL (Distributed SQL)
NewSQL, now usually called distributed SQL, describes relational databases that keep SQL and ACID transactions but spread data across many machines like NoSQL systems do. You talk to it like PostgreSQL or MySQL, while underneath the tables are split into ranges, every range is replicated with a consensus protocol (Paxos or Raft), and a node or even a whole datacenter can fail without losing committed data. The trade-off is latency: a write must reach a majority of replicas before it commits.
How it works
- Split. Each table (and index) is cut into ranges by primary key, typically tens to hundreds of MB each. Ranges split and move automatically as data grows. See Sharding.
- Replicate with consensus. Each range has 3 or 5 replicas forming a Raft or Paxos group. A write commits when a majority acknowledges it, so there is no data loss when a minority fails. See Replication.
- Transactions across ranges. A transaction touching rows in different ranges uses a two-phase commit coordinated across the consensus groups.
- Ordering with clocks. To give a global order to transactions, Spanner uses TrueTime (GPS and atomic clocks with bounded uncertainty); CockroachDB and YugabyteDB use hybrid logical clocks; TiDB uses a central timestamp oracle. See Clock.
In CAP terms these systems are CP: a minority side of a partition stops accepting writes rather than diverge.
Popular systems
| Database | Compatible with | License / delivery | Notes |
|---|---|---|---|
| Google Spanner | GoogleSQL, PostgreSQL dialect | Managed (Google Cloud) | The original (2012 paper). External consistency via TrueTime. |
| CockroachDB | PostgreSQL wire protocol | Source-available; since late 2024 one Enterprise license, free for small companies | Inspired by Spanner; multi-region tables with data placement rules. |
| TiDB | MySQL | Apache 2.0 | Row store (TiKV) plus a columnar replica (TiFlash) for analytics on the same data. |
| YugabyteDB | PostgreSQL (reuses Postgres query layer) | Apache 2.0 | Also offers a Cassandra-compatible API. |
| Amazon Aurora DSQL | PostgreSQL | Managed (AWS), GA 2025 | Serverless, multi-region active-active; some Postgres features unsupported. |
Note that Amazon Aurora (non-DSQL) and Neon separate storage from compute but still have a single writer; they scale reads and storage, not write throughput.
When to use one
- Good fit: you need relational data and strong consistency, but more write throughput, data size or regional resilience than one primary can give: global payments, inventory, user accounts across regions.
- Probably not needed: a single PostgreSQL with replicas handles the load. Distributed SQL adds per-write latency, cost and operational complexity, and some features (certain extensions, triggers, sequences) behave differently or are missing.
Common mistakes
- Sequential primary keys (auto-increment ids, timestamps) send every insert to the last range, creating a hotspot. Use UUIDs or hash-sharded indexes.
- Expecting single-node latency. Each commit waits for a quorum, and multi-region quorums add tens of milliseconds.
- Long, wide transactions that touch many ranges retry more often under contention.
Learning Resources
- Spanner: Google’s Globally-Distributed Database (OSDI 2012)
- CockroachDB: The Resilient Geo-Distributed SQL Database (SIGMOD 2020)
- In Search of an Understandable Consensus Algorithm (Raft) and the Raft visualization
- CockroachDB docs, TiDB docs, YugabyteDB docs
- What’s Really New with NewSQL?: Pavlo and Aslett, 2016