DBDB.io The Encyclopedia of Database Systems · Est. 2017
Database of Databases

Database Entry

CockroachDB


CockroachDB is a scalable, fault-tolerant, SQL database built on a transactional and strongly-consistent key-value store. It is backed by RocksDB and uses distributed consensus algorithm to ensure consistency, it is inspired by Spanner wait commit to implement serializable. It is currently in beta. (Because CockroachDB is rapidly changing, so many findings are based on design document, outdated documentation or available code.)[02][05]

Source Code
https://github.com/cockroachdb/cockroach[02]
Developer
Country of Origin
US
Start Year
2014 [19]
Project Types
Commercial, Open Source
Written in
Go
Supported Languages
Go
Derived From
RocksDB
Inspired By
Cloud Spanner
Compatible With
PostgreSQL
Operating Systems
Linux, macOS, Windows
License
Apache v2

Database Entry

CockroachDB


CockroachDB is a scalable, fault-tolerant, SQL database built on a transactional and strongly-consistent key-value store. It is backed by RocksDB and uses distributed consensus algorithm to ensure consistency, it is inspired by Spanner wait commit to implement serializable. It is currently in beta. (Because CockroachDB is rapidly changing, so many findings are based on design document, outdated documentation or available code.)[02][05]

History[06][07][08]


CockroachDB is inspired by Google’s Spanner and F1 to address fault tolerance and distributed consistency.

Concurrency Control[05]


Transactions in CockroachDB is implemented

Data Model[05]


Foreign Keys[09]


The design for foreign key is under discussion.

Indexes[10][11][12]


CockroachDB supports primary key, secondary index. The indexes are implemented with the distributed key-value store ranges.

Isolation Levels[05][13][14]


CockroachDB supports snapshot isolation (SI) and serializable snapshot isolation (SSI). It is implemented using RocksDB snapshot capability.

Joins[15]


Because CockroachDB is backed by key value store. There are two ways of join in CockroachDB, join-by-lookup and stream joins. Join-by-lookup iterate through one table and lookup for it in the other table. Stream joins is an execution plan based on hashing.

Logging[05]


There's no logging in CockroachDB because it adopts MVCC and uses transaction table to control transactions.

Query Compilation


Query Execution[16]


The query execution is similar to stream processing. When executing a query, the execution plan is transformed into a DAG, a gateway node orchestrates participating nodes begin processing.

Query Interface[17]


SQL

CockroachDB aims to provide standard SQL with extensions, but some standard SQL functionality is under development.

Storage Architecture[05]


The backend storage in CockroachDB is RocksDB. It is disk-oriented storage.

Storage Model[18]


CockroachDB stores its data in the distributed key-value store.

Stored Procedures


System Architecture[05]


CockroachDB has two layers, the SQL layer and the storage layer. The SQL layer sits on top of the transactional and strongly-consistent distributed key-value store. In the key-value store, the key ranges are divided and stored in RocksDB and replicated across cluster. It exports structured data API of relational concepts. It exports standard SQL interface at the SQL layer. The SQL layer translates SQL statements into calls to structured data API.

Views


Citations

19 sources
  1. CockroachDB | Distributed SQL for always-on customer experiences cockroachlabs.com
  2. GitHub - cockroachdb/cockroach: CockroachDB — the cloud native, distributed SQL database designed for high availability, effortless scale, and control over data placement. · GitHub github.com
  3. CockroachDB Docs cockroachlabs.com
  4. CockroachDB - Wikipedia wikipedia.org
  5. cockroach/docs/design.md at master · cockroachdb/cockroach · GitHub github.com Dead — Check Archive
  6. CockroachDB FAQs cockroachlabs.com
  7. Spanner: Google’s Globally-Distributed Database | USENIX usenix.org
  8. F1 - The Fault-Tolerant Distributed RDBMS Supporting Google's Ad Business research.google
  9. FKs RFC by dt · Pull Request #6309 · cockroachdb/cockroach · GitHub github.com
  10. https://pkg.go.dev/github.com/cockroachdb/cockroach/sql?utm_source=godoc go.dev Dead — Check Archive
  11. https://github.com/cockroachdb/cockroach/blob/master/storage/scanner_test.go github.com Dead — Check Archive
  12. SQL in CockroachDB: Mapping table data to key-value storage cockroachlabs.com
  13. cockroach/storage/replica_raftstorage.go at 266e50907fbc7b0769ab6afd10892b16cc02c371 · cockroachdb/cockroach · GitHub github.com Dead — Check Archive
  14. cockroach/storage/engine/rocksdb.go at 5c4631f4b7328764ab150938974766d7e63c746a · cockroachdb/cockroach · GitHub github.com
  15. https://github.com/cockroachdb/cockroach/blob/master/docs/RFCS/distributed_sql.md github.com Dead — Check Archive
  16. https://github.com/cockroachdb/cockroach/blob/master/docs/RFCS/distributed_sql.md#execution-infrastructure github.com Dead — Check Archive
  17. https://www.cockroachlabs.com/docs/learn-cockroachdb-sql.html cockroachlabs.com Dead — Check Archive
  18. https://pkg.go.dev/github.com/cockroachdb/cockroach/storage?utm_source=godoc go.dev Dead — Check Archive
  19. About cockroachlabs.com
Revision #6