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
Tip the Site
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat Pay
Alipay
Open WeChat or Alipay and scan. No login required.
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,...
* 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...
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....
| 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...
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...
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...
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...
SQL- Explaining and Tracing SQL – DISTSQL, EXPLAIN Options by Edie Freedman, Ellie Volckhausen, and Karen Montgomery. The cover fonts are Gilroy Semibold and...
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.
Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat PayAlipay
Open WeChat or Alipay and scan. No login required.
Add Tag
Enter tag name (max 50 characters)
Share E-Book
CockroachDB The Definitive Guide, 2nd Edition (for Raymond Rhine) (Guy Harrison, Jesse Seldess, Ben Darnell etc.)(Z-Library)
Scan QR code with your phone to access
Copy the link or scan the QR code to access this e-book on your phone
Share to WeChat Moments
CockroachDB The Definitive Guide, 2nd Edition (for Raymond Rhine) (Guy Harrison, Jesse Seldess, Ben Darnell etc.)(Z-Library)
Scan the QR code with WeChat to open this book
Tap the ··· menu in the top-right corner
Choose Share to Moments
You are already in WeChat. Tap ··· in the top-right corner and choose Share to Moments.
Share E-Book via Email
Please enter email address
Donation Statistics
¥.00
Total Donations
0
Donation Count
CockroachDB The Definitive Guide, 2nd Edition (for Raymond Rhine) (Guy Harrison, Jesse Seldess, Ben Darnell etc.)(Z-Library)
Find Your Favorite Books
Only registered users can comment after logging in. Comments need to be reviewed by administrators before being displayed
这本书面向软件开发人员、架构师以及 DevOps 和 SRE 团队,系统讲解如何用 CockroachDB 构建能够弹性伸缩、对最终用户保持无缝交付、同时具备高可靠性的数据驱动型应用。作为一本广受欢迎的实操指南的第二版,它把分布式 SQL 数据库的能力与真实工程场景结合起来,既谈数据库本身,也谈围绕它的部署与运维决策。
从给出的材料看,读者可以抓住几条主要线索。其一是查询能力的深入使用:书中涉及连接与聚合的写法,例如在用户与骑手收入数据之间做关联并按收入总和排序;也讲到递归公共表表达式,使查询能够引用自身,从而处理层级或深度不确定的数据。其二是事务与一致性:通过 AS OF SYSTEM TIME 子句在事务中读取某一时间点的数据,可以避免并发写入导致事务失败,这直接关系到分布式环境下如何稳定地读取一致快照。其三是部署层面的准备:高级部署方式虽然省去大量工作,但在动手之前仍需做出若干前置决策,比如选择云服务商和区域。其四是权限与角色管理:用户与角色在某种程度上可以互换,但角色默认配置为 NOLOGIN,阻止客户端直接以角色身份认证;权限可以授予用户或角色,通常有更便捷的做法。
Digital LibraryAI Assistant
Hi — I can help you pick a book. Tell me a topic, language, or level, e.g. “a light English read”. If that's too broad, I'll ask one follow-up.
Loading comments...
Reply to Comment
Edit Comment