CockroachDB The Definitive Guide, 2nd Edition (for Raymond Rhine) (Guy Harrison, Jesse Seldess, Ben Darnell etc.) (z-library.sk, 1lib.sk, z-lib.sk)
Database
CockroachDB is the distributed SQL database that handles the demands of today’s data-driven applications. The second edition of this popular hands-on guide shows software developers, architects, and DevOps/SRE teams how to use CockroachDB for applications that scale elastically and provide seamless delivery for end users while remaining indestructible.
AI Reading Assistant
Whole-book reading guide from stratified index samples; jump to passages in the text
AI guide
【One-Line Pitch】
A hands-on guide to building, tuning, and operating applications on CockroachDB, the distributed SQL database designed for elastic scale and resilience. Best for developers, architects, and DevOps/SRE teams who already know SQL and want to move from a local test cluster to production-grade, multi-region deployments.
【Book Arc】
- **Opening (~0%–12%)**: Establishes context — the evolution of databases toward distributed cloud SQL — then covers CockroachDB's architecture, its relationship to (and divergence from) Spanner, and where it fits versus analytic-only platforms. Solves the "what is this and when should I use it" question.
- **Early (~12%–31%)**: Gets you running: local install, CockroachDB Cloud Basic, Docker/Kubernetes, certificates, sample workloads, and the SQL dialect (CTEs, recursive queries, column definitions, upserts). Then moves into schema design — keys, constraints, normalization vs. denormalization, and indexing.
- **Middle (~31%–54%)**: Application development in practice: CRUD across language drivers, transaction patterns (optimistic retry vs. pessimistic `FOR UPDATE`), serializable isolation trade-offs, `AS OF SYSTEM TIME` reads, data import/migration from MySQL and PostgreSQL, and change data capture (changefeeds to Kafka, JSON/Avro).
- **Late (~54%–end of excerpts)**: Query tuning and diagnostics — `EXPLAIN` output, full scans, join strategies (hash/merge/lookup) and how sensitive they are to data distribution. Excerpts do not cover the later deployment, backup, and disaster-recovery chapters in detail.
- **Ending**: Part III is described as covering single- and multi-region deployment planning, backup, and disaster recovery, but the excerpts stop before this material, so treat those chapters as unverified here.
【Key Takeaways】
- **CockroachDB targets transactional workloads first** (Opening): it supports aggregations, windowing functions, and BI tools, but its differentiating features are aimed at transactions — analytic-only workloads may do better elsewhere.
- **It is inspired by Spanner, not a clone** (Opening): notably, it does not assume special hardware like atomic clocks or GPS, which shapes its design choices.
- **Ranges split on size and on load** (Opening): a range exceeding the ~512 MB threshold splits, and hot ranges can split earlier based on QPS thresholds, with the split point chosen to balance load.
- **Getting started is deliberately low-friction** (Early): desktop install, free cloud tier, Docker, or Kubernetes, plus built-in sample schemas (bank, intro, kv, movr, startrek, tpcc) for practicing.
- **Schema design favors artificial keys** (Early): they perform better, avoid the overhead of changing natural keys, and help distribute keys evenly across the cluster; foreign keys are often disabled in production for overhead reasons.
- **Denormalization is a deliberate performance trade** (Early): reintroducing redundancy — e.g., storing foreign keys in an array instead of a join table — buys speed at the cost of normalization purity.
- **Serializable isolation means conflicts are real** (Middle): CockroachDB's default is stricter than many SQL databases, so plan for retries (optimistic) or `FOR UPDATE` locking (pessimistic); retry logic is recommended either way.
- **Read `EXPLAIN` for full scans** (Late): a `spans: FULL SCAN` often signals a missing index or a missing leading column in the `WHERE` clause, and join strategy choices are highly sensitive to data distribution.
【Reading Tips】
- Skim Part I's historical framing if you already know distributed SQL; slow down on the architecture and range-splitting sections, since they explain later behavior.
- Treat the sample workloads (movr, tpcc, etc.) as your lab — run them locally before touching schema design or tuning chapters.
- Deep-read the transaction and isolation material; it is the most common source of production surprises and the hardest to retrofit later.
- Use the `EXPLAIN` and join-performance sections as a reference while tuning real queries rather than reading them linearly.
- If you are an SRE, jump ahead to Part III's deployment/backup material once you have the schema and transaction basics.
【Coverage Limits】
This guide is based on stratified excerpts covering roughly the first half of the book; the deployment, backup, and disaster-recovery chapters in Part III are described but not substantively covered, so specifics there are not verified.
Excerpt 1
mes were introduced to facilitate efficient data processing and implement constraints. Indexes and clustered storage were not a part of the relational model,...
View in text
Excerpt 2
* FROM "users" u2 JOIN riderRevenue rr USING (id) ORDER BY sumrevenue DESC; The RECURSIVE clause allows the Common Table Expression to refer to itself, poten...
View in text
Excerpt 3
l the columns in a result set and converts them to an array. In the prior example, we copied all the class_id values for each student into the classes array....
View in text
Excerpt 4
| xlog_position The changefeed will continue indefinitely. To terminate the changefeed, you would hit Control-C from a SQL prompt or, in a programming langua...
View in text
Excerpt 5
s A CockroachDB Advanced deployment takes away a lot of the effort for a CockroachDB deployment, but there are still some predeployment decisions to make. Fi...
View in text
Excerpt 6
racting with any external Kafka services. Let’s fix that by allowing the external connectivity to Kafka. First we’ll create a file that contains the rules th...
View in text
Excerpt 7
ind those SQL statements. Secondly, a typical cause of poor performance is the introduction of a new or unique SQL statement that is causing problems. Object...
View in text
Excerpt 8
SQL- Explaining and Tracing SQL – DISTSQL, EXPLAIN Options by Edie Freedman, Ellie Volckhausen, and Karen Montgomery. The cover fonts are Gilroy Semibold and...
View in text
Tags
AI categories
DatabaseSQLBackend
Text Preview (First 20 pages)
Registered users can read the full content for free
Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.
Generating text preview…
Loading comments...
Reply to Comment
Edit Comment