Database: CockroachDB basics
CockroachDB is a relational database that spreads data across machines and keeps SQL transactions working. The lessons explain how tables are split into key ranges replicated through Raft, why every write needs a majority, and how clock uncertainty causes transaction retries. They cover which Postgres features and Active Record code carry over, why sequential primary keys create hot ranges, and how REGIONAL BY ROW and GLOBAL tables place data. The course ends by costing a migration of this application and naming the facts that would change the answer.
What you'll learn
- ✓How key ranges, replication and Raft consensus shape write latency
- ✓Why clock uncertainty restarts transactions and why code needs retry loops
- ✓Which Postgres features carry over to CockroachDB and which break
- ✓Why sequential primary keys create hot ranges
- ✓Placing data with REGIONAL BY ROW and GLOBAL tables
- ✓Weighing a migration against triggers you can measure
What distributed SQL means
Distributed SQL claims you can have a relational database with transactions and joins, spread across many machines, without sharding it yourself. That claim deserves a careful look, because half of it is true and the other half has a price.
Read the full lesson free →Curriculum
7 lessonsWhat distributed SQL means
How distributed SQL splits tables into replicated key ranges, uses Raft consensus, and pays for it in write latency.
The clock problem
Why drifting clocks make ordering hard, and how CockroachDB restarts transactions inside a 500 ms uncertainty window.
What your SQL still does
What carries over through the PostgreSQL wire protocol, why sequential keys create hot ranges, and which features break.
Where the data sits
How REGIONAL BY ROW and GLOBAL tables place data by geography or by law, and what that requires.
What a migration would cost
The schema, Solid Queue, Solid Cache, transaction and operational costs of moving this application from Postgres.
When the answer would be yes
Which facts would reverse the recommendation: data residency, write volume beyond one machine, and contractual availability.
Putting it together
A recap of the course and a challenge to model write latency under majority consensus.