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

Database Entry

CockroachDB


CockroachDB (sometimes shortened as CRDB) is a free and open source distributed SQL database built on a transactional and strongly-consistent key-value store. It is backed by PebbleDB (a RocksDB/LevelDB-inspired K/B store) and uses the Raft distributed consensus algorithm to ensure consistency.[02][06]

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

Database Entry

CockroachDB


CockroachDB (sometimes shortened as CRDB) is a free and open source distributed SQL database built on a transactional and strongly-consistent key-value store. It is backed by PebbleDB (a RocksDB/LevelDB-inspired K/B store) and uses the Raft distributed consensus algorithm to ensure consistency.[02][06]

History[07][08][09]


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

Concurrency Control[06]


Data Model[06]


Foreign Keys[10]


CockroachDB supports foreign keys.

Indexes[11][12][13]


CockroachDB's indexes are stored in RocksDB's LSM tree implementation.

Isolation Levels[06][14][15]


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

Joins[16]


CockroachDB supports all standard SQL joins. Distributed joins are performed via a shuffle by hash strategy, or a batched nested loop strategy. Broadcast joins are not supported.

Logging[06]


Query Compilation


Query Execution[17]


CockroachDB supports distributed SQL execution. The gateway query node is responsible for creating a DAG of SQL processors and distributing them across the cluster, like in F1. The individual SQL processors operate in either a tuple-at-a-time mode, which supports all SQL queries in CockroachDB, or a vectorized mode, which supports a subset of SQL, depending on query cardinality.

Query Interface[18]


SQL

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

Storage Architecture[06]


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

Storage Model[19]


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

Storage Organization


Stored Procedures


System Architecture[06]


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

20 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. https://twitter.com/CockroachDB twitter.com
  6. cockroach/docs/design.md at master · cockroachdb/cockroach · GitHub github.com Dead — Check Archive
  7. CockroachDB FAQs cockroachlabs.com
  8. Spanner: Google’s Globally-Distributed Database | USENIX usenix.org
  9. F1 - The Fault-Tolerant Distributed RDBMS Supporting Google's Ad Business research.google
  10. Foreign Key Constraint cockroachlabs.com
  11. https://pkg.go.dev/github.com/cockroachdb/cockroach/sql?utm_source=godoc go.dev Dead — Check Archive
  12. https://github.com/cockroachdb/cockroach/blob/master/storage/scanner_test.go github.com Dead — Check Archive
  13. SQL in CockroachDB: Mapping table data to key-value storage cockroachlabs.com
  14. cockroach/storage/replica_raftstorage.go at 266e50907fbc7b0769ab6afd10892b16cc02c371 · cockroachdb/cockroach · GitHub github.com Dead — Check Archive
  15. cockroach/storage/engine/rocksdb.go at 5c4631f4b7328764ab150938974766d7e63c746a · cockroachdb/cockroach · GitHub github.com
  16. https://github.com/cockroachdb/cockroach/blob/master/docs/RFCS/distributed_sql.md github.com Dead — Check Archive
  17. https://github.com/cockroachdb/cockroach/blob/master/docs/RFCS/distributed_sql.md#execution-infrastructure github.com Dead — Check Archive
  18. https://www.cockroachlabs.com/docs/learn-cockroachdb-sql.html cockroachlabs.com Dead — Check Archive
  19. https://pkg.go.dev/github.com/cockroachdb/cockroach/storage?utm_source=godoc go.dev Dead — Check Archive
  20. About cockroachlabs.com
Revision #15