Share E-Book
Scan to open this page

Scan with your phone to open this page

Author: Guy Harrison, Jesse Seldess, Ben Darnell, Rob Reid

Rating No ratings yet

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. Data professionals will learn how to migrate existing applications to CockroachDB's performant, cloud-native data architecture. You'll also quickly discover the benefits of strong data correctness and consistency guarantees, plus optimizations for delivering ultra-low latencies to globally distributed end users. Uncover the power of distributed SQL Learn how to start, manage, and optimize projects in CockroachDB Explore best practices for data modeling, schema design, and distributed infrastructure Discover strategies for migrating data into CockroachDB See how to read, write, and run ACID transactions across distributed systems Maximize resiliency in multiregion clusters Secure, monitor, and fine-tune your CockroachDB deployment for peak performance

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 and running applications on CockroachDB, the distributed SQL database that trades a little latency for always-on availability and strict consistency. Best for developers, architects, and SRE/DevOps teams who already know relational databases and now need to operate at global scale. 【Book Arc】 - **Opening (~0%–10%)**: Frames CockroachDB against the history of databases—from monolithic RDBMSs to eventually-consistent NoSQL—and explains why the authors built a strongly consistent, highly available SQL system. Solves the "why does this database exist?" question. - **Early (~10%–35%)**: Moves into internals and setup: the KV storage layer (Pebble, LSM trees, SSTables), cluster architecture, installation on Linux/macOS/Windows, connection URLs, and creating clusters via Terraform. Solves "how do I get a cluster running and understand what's underneath?" - **Middle (~35%–55%)**: Core SQL and schema work—SELECT, data types (including ARRAY, JSONB, ENUM, VECTOR), views and materialized views, UDFs, UPSERT, and the beginnings of table/index creation. Solves "how do I model and query data?" - **Late (~55%–80%)**: Application design and implementation—CRUD operations, connection pools, prepared/parameterized statements, plus index strategy (composite, covering, inverted, partial, hash-sharded) and physical design. Solves "how do I make this fast and correct in real code?" - **Ending (~80%–100%)**: Operational maturity—migration strategies, multiregion resiliency, security, monitoring, and performance tuning. Solves "how do I keep this running at scale?" (Excerpts do not cover these chapters in detail.) 【Key Takeaways】 - **CockroachDB prioritizes consistency over availability, but still targets very high availability** (Early): It was built as a corrective to NoSQL's weak guarantees, keeping SQL and ACID transactions while distributing across nodes. - **It is wire-compatible with PostgreSQL** (Middle): Most Postgres drivers work unchanged—there are no CockroachDB-specific drivers—so existing Java, Go, Python, and JavaScript tooling transfers directly. - **The storage layer is an LSM-tree KV engine called Pebble** (Early): MemTables flush to SSTables across levels L0–L6, giving fast writes and efficient random reads; older versions used RocksDB. - **Schema and index design are first-class concerns** (Late): Composite, covering, inverted, partial, expression, full-text, spatial, and hash-sharded indexes each solve distinct access patterns, and the book treats index overhead as a real cost. - **Rich data types reduce the need for workarounds** (Middle): ARRAY, JSONB, ENUM, INET, UUID, and VECTOR (for embeddings) are native, alongside standard numeric, string, and temporal types. - **Views and functions are part of the modeling toolkit** (Middle): Standard and materialized views, plus SQL/PL-pgSQL user-defined functions, let you encapsulate logic in the database. - **Operational concerns are treated as engineering, not afterthoughts** (Late): Connection pooling, prepared statements, Terraform-based cluster provisioning, and the DB Console for metrics all appear as practical guidance. - **Real-world scale is the framing throughout** (Early): Case material such as Route processing billions of orders illustrates the elastic scale-up/scale-down promise with zero downtime. 【Reading Tips】 - **Skim the history chapter if you already know the NoSQL-vs-SQL story**; deep-read the storage-layer and architecture sections, since they explain *why* CockroachDB behaves the way it does under load. - **Treat the SQL and data-type chapters as a reference**, not a linear read—jump to the type or statement you need, then return to index design once your queries are stable. - **Pay closest attention to the index and application-design chapters**; this is where most real performance and correctness wins (or losses) happen. - **If you're migrating an existing Postgres app**, read the compatibility notes carefully—CockroachDB diverges in specific areas (e.g., no PostgreSQL XML functions). - **Keep the operational chapters for last**, but don't skip them: multiregion resiliency, security, and monitoring are where distributed databases actually get hard. 【Coverage Limits】 This guide is synthesized from stratified excerpts covering roughly the first half of the book; the later chapters on migration, multiregion resiliency, security, monitoring, and performance tuning are referenced but not detailed here.
Excerpt 1
139 Attributes to Columns 140 Primary Key Design 141 Foreign Key Constraints 146 Denormalization 147 Replicating Columns to Avoid Joins 147 Summary Tables 14...
View in text
Excerpt 2
ing to the redefinition of NoSQL as “not only SQL.” In many cases, these SQL implementations were query-only and intended only to support A Brief History of...
View in text
Excerpt 3
ning without authentication would look something like this: $ cockroach sql --url 'postgres://root@localhost:26257?sslmode=disable' # # Welcome to the Cockro...
View in text
Excerpt 4
array of floating-point numbers representing [0.1259227, 0.0318873, points in an n-dimensional space. 0.4660917] 102 | Chapter 4: CockroachDB SQL Views A sta...
View in text
Excerpt 5
to perform a full table scan. It would have to read each of the email values, extract the domain from the email address, and test it against the given value...
View in text
Excerpt 6
401a2b9', ARRAY['g', 'h', 'i'], 'purchased', now() After a short while (as defined by our ttl_job_cron parameter), the inactive pending basket and the purcha...
View in text
Excerpt 7
) function copies data from PostgreSQL to CockroachDB using SELECT and INSERT statements. You could substitute a more performant extract and load procedure u...
View in text
Excerpt 8
info project └── select ├── scan rides │ ├── constraint: /2/1: [/’amsterdam’—/’amsterdam’] │ └── flags: force-index=primary └── filters └── end_address = '57...
View in text
Tags
AI categories
DatabaseSQLBackend
ISBN: 1098179846
Publisher: O’Reilly Media
Publish Year: 2025
Language: English
Pages: 541
File Format: PDF
File Size: 5.9 MB
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…