Preface |
|
xv | |
|
Part I Introduction to CockroachDB |
|
|
|
1 Introduction to CockroachDB |
|
|
3 | (16) |
|
A Brief History of Databases |
|
|
3 | (1) |
|
|
4 | (1) |
|
|
5 | (2) |
|
Implementing the Relational Model |
|
|
7 | (1) |
|
|
7 | (1) |
|
|
8 | (1) |
|
|
8 | (1) |
|
|
9 | (2) |
|
|
11 | (1) |
|
The Emergence of Distributed SQL |
|
|
11 | (2) |
|
The Advent of CockroachDB |
|
|
13 | (1) |
|
|
14 | (2) |
|
|
16 | (1) |
|
|
16 | (1) |
|
CockroachDB at DevSisters |
|
|
17 | (1) |
|
|
17 | (1) |
|
|
17 | (1) |
|
|
18 | (1) |
|
2 CockroachDB Architecture |
|
|
19 | (32) |
|
The CockroachDB Cluster Architecture |
|
|
20 | (1) |
|
|
21 | (1) |
|
The CockroachDB Software Stack |
|
|
22 | (1) |
|
The CockroachDB SQL Layer |
|
|
23 | (2) |
|
|
25 | (1) |
|
Tables as Represented in the KV Store |
|
|
25 | (1) |
|
|
26 | (1) |
|
|
27 | (1) |
|
|
28 | (1) |
|
|
28 | (1) |
|
Table Definitions and Schema Changes |
|
|
29 | (1) |
|
The CockroachDB Transaction Layer |
|
|
30 | (1) |
|
|
31 | (1) |
|
|
32 | (1) |
|
|
33 | (1) |
|
|
34 | (1) |
|
|
35 | (1) |
|
Overview of Transaction Flow |
|
|
35 | (2) |
|
|
37 | (1) |
|
Clock Synchronization and Clock Skew |
|
|
38 | (1) |
|
The CockroachDB Distribution Layer |
|
|
39 | (1) |
|
|
39 | (1) |
|
|
40 | (1) |
|
|
40 | (1) |
|
|
41 | (1) |
|
|
42 | (1) |
|
The CockroachDB Replication Layer |
|
|
43 | (1) |
|
|
43 | (1) |
|
|
44 | (1) |
|
Closed Timestamps and Follower Reads |
|
|
44 | (1) |
|
The CockroachDB Storage Layer |
|
|
45 | (1) |
|
Log-Structured Merge Trees |
|
|
45 | (2) |
|
SSTables and Bloom Filters |
|
|
47 | (1) |
|
|
48 | (1) |
|
MultiVersion Concurrency Control |
|
|
48 | (1) |
|
|
48 | (1) |
|
|
49 | (2) |
|
|
51 | (28) |
|
|
51 | (1) |
|
Installing CockroachDB Software |
|
|
51 | (4) |
|
Creating a CockroachDB Serverless Instance |
|
|
55 | (4) |
|
Starting a Local Single-Node Server |
|
|
59 | (2) |
|
Starting Up CockroachDB in a Docker Container |
|
|
61 | (1) |
|
Starting Up a Secure Server |
|
|
62 | (1) |
|
|
63 | (1) |
|
|
64 | (1) |
|
Creating a Kubernetes Cluster |
|
|
64 | (2) |
|
|
66 | (1) |
|
|
67 | (1) |
|
|
67 | (3) |
|
|
70 | (1) |
|
|
71 | (1) |
|
|
72 | (1) |
|
Working with Programming Languages |
|
|
72 | (1) |
|
Connecting to CockroachDB from Node.js |
|
|
73 | (1) |
|
Connecting to CockroachDB from Java |
|
|
74 | (1) |
|
Connecting to CockroachDB from Python |
|
|
75 | (2) |
|
Connecting to CockroachDB from Go |
|
|
77 | (1) |
|
|
78 | (1) |
|
|
79 | (40) |
|
SQL Language Compatibility |
|
|
80 | (1) |
|
Querying Data with SELECT |
|
|
80 | (1) |
|
|
81 | (1) |
|
|
81 | (1) |
|
|
82 | (1) |
|
|
83 | (1) |
|
|
83 | (1) |
|
|
83 | (1) |
|
|
84 | (1) |
|
|
85 | (1) |
|
|
85 | (1) |
|
|
85 | (1) |
|
|
86 | (1) |
|
|
86 | (1) |
|
|
87 | (1) |
|
|
88 | (1) |
|
|
89 | (1) |
|
|
89 | (2) |
|
|
91 | (2) |
|
|
93 | (1) |
|
Creating Tables and Indexes |
|
|
93 | (2) |
|
|
95 | (1) |
|
|
95 | (1) |
|
|
96 | (1) |
|
|
97 | (1) |
|
|
98 | (1) |
|
|
98 | (3) |
|
|
101 | (1) |
|
|
101 | (2) |
|
|
103 | (1) |
|
|
103 | (1) |
|
|
104 | (2) |
|
|
106 | (1) |
|
|
107 | (1) |
|
|
108 | (1) |
|
|
108 | (1) |
|
|
108 | (1) |
|
|
109 | (1) |
|
|
109 | (1) |
|
|
110 | (1) |
|
|
110 | (1) |
|
|
110 | (1) |
|
|
111 | (1) |
|
|
112 | (1) |
|
Other Data Definition Language Targets |
|
|
112 | (1) |
|
|
113 | (1) |
|
|
114 | (1) |
|
|
115 | (4) |
|
Part II Developing Applications with CockroachDB |
|
|
|
5 CockroachDB Schema Design |
|
|
119 | (38) |
|
|
120 | (1) |
|
|
121 | (1) |
|
|
122 | (1) |
|
|
123 | (1) |
|
|
124 | (1) |
|
|
124 | (1) |
|
|
125 | (1) |
|
|
126 | (1) |
|
|
127 | (5) |
|
|
132 | (1) |
|
|
133 | (1) |
|
Replicating Columns to Avoid Joins |
|
|
133 | (2) |
|
|
135 | (1) |
|
|
135 | (1) |
|
|
136 | (1) |
|
|
137 | (1) |
|
|
138 | (1) |
|
JSON Document Antipatterns |
|
|
139 | (1) |
|
|
139 | (1) |
|
Using JSON or Arrays to Avoid Joins |
|
|
140 | (3) |
|
|
143 | (1) |
|
|
143 | (1) |
|
|
143 | (2) |
|
|
145 | (1) |
|
|
146 | (1) |
|
|
147 | (1) |
|
Composite and Covering Index Performance |
|
|
148 | (1) |
|
Guidelines for Composite Indexes |
|
|
149 | (1) |
|
|
149 | (1) |
|
|
149 | (1) |
|
|
150 | (1) |
|
|
150 | (1) |
|
|
151 | (1) |
|
|
151 | (1) |
|
|
152 | (1) |
|
Measuring Index Effectiveness |
|
|
153 | (1) |
|
|
154 | (3) |
|
6 Application Design and Implementation |
|
|
157 | (36) |
|
|
157 | (1) |
|
Performing CRUD Operations |
|
|
158 | (3) |
|
|
161 | (4) |
|
Prepared and Parameterized Statements |
|
|
165 | (2) |
|
|
167 | (2) |
|
|
169 | (4) |
|
|
173 | (1) |
|
|
174 | (2) |
|
|
176 | (1) |
|
|
177 | (1) |
|
Implementing Transaction Retries |
|
|
178 | (1) |
|
Automatic Transaction Retries |
|
|
179 | (1) |
|
Avoiding Transaction Retry Errors with FOR UPDATE |
|
|
180 | (2) |
|
Reducing Contention by Eliminating Hot Rows |
|
|
182 | (1) |
|
Reducing Transaction Elapsed Time |
|
|
183 | (1) |
|
|
184 | (1) |
|
|
184 | (1) |
|
Ambiguous Transactions Errors |
|
|
185 | (1) |
|
|
186 | (1) |
|
|
187 | (1) |
|
Working with ORM Frameworks |
|
|
187 | (4) |
|
|
191 | (2) |
|
7 Application Migration and Integration |
|
|
193 | (40) |
|
|
193 | (1) |
|
|
194 | (2) |
|
|
196 | (1) |
|
Importing from Cloud Storage |
|
|
197 | (2) |
|
|
199 | (1) |
|
Migrating from Another Database |
|
|
199 | (1) |
|
Extracting and Converting DDL |
|
|
199 | (6) |
|
General Considerations When Converting DDL |
|
|
205 | (1) |
|
|
206 | (1) |
|
Loading Data Into CockroachDB |
|
|
207 | (1) |
|
Directly Importing PostgreSQL or MySQL Dumps |
|
|
208 | (1) |
|
Synchronizing and Switching Over |
|
|
209 | (4) |
|
Updating Application Code |
|
|
213 | (1) |
|
Exporting CockroachDB Data |
|
|
214 | (2) |
|
|
216 | (1) |
|
|
216 | (2) |
|
Using the Changefeed Programmatically |
|
|
218 | (2) |
|
Enterprise Change Data Capture |
|
|
220 | (5) |
|
Change Data Capture to Kafka |
|
|
225 | (1) |
|
Change Data Capture to Snowflake |
|
|
226 | (5) |
|
|
231 | (2) |
|
|
233 | (48) |
|
|
233 | (3) |
|
Explaining and Tracing SQL |
|
|
236 | (4) |
|
|
240 | (2) |
|
|
242 | (3) |
|
|
245 | (1) |
|
|
246 | (1) |
|
|
247 | (10) |
|
|
257 | (1) |
|
|
257 | (11) |
|
Optimizing Sorting and Aggregation |
|
|
268 | (5) |
|
|
273 | (2) |
|
|
275 | (1) |
|
|
275 | (1) |
|
|
275 | (1) |
|
|
276 | (1) |
|
Manually Collecting Statistics |
|
|
277 | (1) |
|
|
278 | (3) |
|
Part III Deploying and Administering CockroachDB 9. Planning a Deployment |
|
|
281 | (162) |
|
|
282 | (1) |
|
Comparison of Deployment Options |
|
|
283 | (2) |
|
|
285 | (3) |
|
Single-Region Dedicated Deployments |
|
|
288 | (1) |
|
Common Planning Tasks--Dedicated Deployments |
|
|
288 | (1) |
|
Benchmarking and Capacity Planning |
|
|
288 | (2) |
|
CockroachDB Cloud Deployments |
|
|
290 | (1) |
|
Self-Hosted on a Cloud Platform |
|
|
291 | (2) |
|
Self-Hosted "Bare-Metal" On-Premise |
|
|
293 | (1) |
|
Other Self-Hosted Considerations |
|
|
294 | (1) |
|
|
295 | (1) |
|
Configuring for Self-Hosted High Availability |
|
|
296 | (1) |
|
|
297 | (1) |
|
|
297 | (1) |
|
|
298 | (1) |
|
Zone and Region Topologies |
|
|
298 | (2) |
|
|
300 | (1) |
|
10 Single-Region Deployment |
|
|
301 | (22) |
|
Deploying On-Premise or On-Cloud |
|
|
301 | (1) |
|
|
302 | (1) |
|
Operating System Configuration |
|
|
302 | (1) |
|
Clock Synchronization On-Premise |
|
|
303 | (1) |
|
Clock Synchronization on Cloud Platforms |
|
|
304 | (2) |
|
|
306 | (1) |
|
|
307 | (2) |
|
|
309 | (1) |
|
|
309 | (1) |
|
|
310 | (2) |
|
Installing a Load Balancer (On-Premise) |
|
|
312 | (2) |
|
|
314 | (1) |
|
Configuring Regions and Zones |
|
|
315 | (1) |
|
|
315 | (1) |
|
Initializing the Operator |
|
|
316 | (1) |
|
|
317 | (2) |
|
|
319 | (1) |
|
|
319 | (2) |
|
|
321 | (1) |
|
|
322 | (1) |
|
11 Multiregion Deployment |
|
|
323 | (16) |
|
|
323 | (1) |
|
|
323 | (2) |
|
|
325 | (2) |
|
|
327 | (2) |
|
Planning Your Mutliregion Deployment |
|
|
329 | (1) |
|
|
329 | (3) |
|
Converting to a Multiregion Database |
|
|
332 | (1) |
|
Configuring Regional by Row |
|
|
333 | (3) |
|
Setting Regional Survival Goal |
|
|
336 | (1) |
|
Placement Restricted Databases |
|
|
337 | (1) |
|
|
338 | (1) |
|
12 Backup and Disaster Recovery |
|
|
339 | (18) |
|
|
340 | (1) |
|
|
341 | (1) |
|
|
342 | (1) |
|
|
343 | (1) |
|
Table- and Database-Level Backups |
|
|
343 | (1) |
|
|
344 | (1) |
|
|
344 | (1) |
|
|
345 | (1) |
|
|
345 | (2) |
|
|
347 | (1) |
|
|
348 | (2) |
|
|
350 | (1) |
|
|
351 | (2) |
|
|
353 | (1) |
|
Disaster Recovery Best Practices |
|
|
354 | (1) |
|
Backup Scheduling and Configuration |
|
|
354 | (1) |
|
Recovering from Human Errors |
|
|
355 | (1) |
|
|
356 | (1) |
|
|
357 | (24) |
|
|
358 | (1) |
|
IP Allowlist with CockroachDB Dedicated |
|
|
358 | (1) |
|
VPC Peering and PrivateLink with CockroachDB Dedicated |
|
|
359 | (3) |
|
|
362 | (2) |
|
Configuring a Firewall in GCP |
|
|
364 | (1) |
|
Configuring a Firewall in AWS |
|
|
365 | (1) |
|
Configuring Ports for Microsoft Azure |
|
|
366 | (1) |
|
Encryption and Server Certificates |
|
|
367 | (1) |
|
|
368 | (3) |
|
Authentication Mechanisms |
|
|
371 | (1) |
|
|
371 | (1) |
|
|
372 | (1) |
|
|
372 | (1) |
|
|
373 | (1) |
|
|
374 | (1) |
|
Fine-Grained Access Control with Views |
|
|
375 | (1) |
|
|
376 | (3) |
|
|
379 | (1) |
|
|
380 | (1) |
|
14 Administration and Troubleshooting |
|
|
381 | (28) |
|
|
381 | (1) |
|
CockroachDB Dedicated Alerts |
|
|
382 | (1) |
|
CockroachDB Serverless Alerts |
|
|
383 | (1) |
|
|
383 | (2) |
|
|
385 | (1) |
|
Monitoring and Alerting with Prometheus |
|
|
386 | (2) |
|
Monitoring and Alerting with Datadog |
|
|
388 | (1) |
|
|
389 | (2) |
|
|
391 | (1) |
|
|
392 | (2) |
|
|
394 | (1) |
|
|
395 | (1) |
|
|
395 | (1) |
|
|
396 | (1) |
|
Logs in Cloud Deployments |
|
|
396 | (1) |
|
|
397 | (1) |
|
Upgrading the Cluster Version |
|
|
397 | (2) |
|
Adding Nodes to a Cluster |
|
|
399 | (1) |
|
|
400 | (3) |
|
|
403 | (1) |
|
Clock Synchronization Errors |
|
|
404 | (1) |
|
|
404 | (1) |
|
|
405 | (2) |
|
Loss of Client Connectivity |
|
|
407 | (1) |
|
Running Out of Disk Space |
|
|
407 | (1) |
|
Working with CockroachDB Support Resources |
|
|
407 | (1) |
|
|
408 | (1) |
|
|
409 | (34) |
|
Tuning Versus Firefighting |
|
|
409 | (2) |
|
|
411 | (1) |
|
Detecting Problem Workloads |
|
|
411 | (8) |
|
Review of Workload Optimization Strategies |
|
|
419 | (2) |
|
Ad Hoc or Analytic Queries |
|
|
421 | (1) |
|
|
422 | (1) |
|
|
423 | (1) |
|
|
424 | (5) |
|
|
429 | (2) |
|
Changes in Cluster Topology |
|
|
431 | (1) |
|
|
432 | (1) |
|
|
433 | (2) |
|
|
435 | (1) |
|
|
436 | (1) |
|
|
437 | (1) |
|
|
438 | (1) |
|
|
438 | (3) |
|
|
441 | (1) |
|
|
441 | (2) |
Index |
|
443 | |