Search DistillSys

Find a concept

Type at least two characters to search lessons, designs, papers, and interview prep.

Storageadvanced7 min read

Distributed SQL

Preserve relational queries and transactions while distributing storage and execution.

2–5 minute refresher
Mental model

SQL plan over ranges + replicated state + distributed transaction protocol

30second
refresher
Distributed SQL systems retain relational schemas, query planning, and transactions while partitioning and replicating data across nodes. They coordinate metadata, timestamps, locks or intents, and query fragments.

What problem does it solve?

Teams want horizontal scale and resilience without abandoning joins, constraints, and transactional invariants.

How it works

  1. Translate SQL into a logical and physical plan.
  2. Route scans and writes to the ranges that own the data.
  3. Push computation near storage and exchange only necessary rows.
  4. Coordinate multi-range writes with timestamps and an atomic commit protocol.
  5. Replicate each range and recover its authority independently.
Decision guide

Key trade-offs

ChoiceWhat you gainWhat it costs
Global transactionsSimple cross-row invariantsCoordination and tail latency
Locality-aware schemaFast common operationsMore deliberate data modeling
Distributed joinsFlexible analyticsNetwork shuffle and memory pressure
What happens if?

One participant is slow during commit

The transaction's latency follows the slowest required participant and may leave an ambiguous client result. Deadlines, durable transaction records, recovery, and idempotent retries are necessary.

Where it appears

  • Google Spanner
  • CockroachDB
  • TiDB
  • YugabyteDB
Senior interview modeWhy can a normalized schema perform poorly in distributed SQL?Show answer
Frequently joined or transactionally updated rows may land on different ranges, turning local operations into distributed scans, shuffles, and commits. Locality-aware keys or selective denormalization can keep the common path local.
#sql#transactions#query planning#consensus