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 KV store) and uses the Raft distributed consensus algorithm to ensure consistency.[05][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
Derived From
RocksDB
Embeds / Uses
Pebble
Inspired By
Cloud Spanner
Compatible With
PostgreSQL
Operating Systems
Hosted, 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 KV store) and uses the Raft distributed consensus algorithm to ensure consistency.[05][06]

History[07][08][09]


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

Concurrency Control[05]


Data Model[05]


Fault Tolerance


Foreign Keys[10]


CockroachDB supports foreign keys.

Indexes[11][12][13]


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

Isolation Levels[05][14][15]


CockroachDB supports Serializable isolation and Read Committed isolation.

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[05]


Query Compilation


CockroachDB implements a MonetDB/X100 style vectorized execution engine, which compiles queries into a tree of monomorphized query execution operators.

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 compatible PostgreSQL with extensions, but some standard SQL functionality is under development.

Storage Architecture[05]


The backend storage in CockroachDB is Pebble, a native Go version of 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[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.

User-Defined Functions


CockroachDB implements SQL and PL/PGSQL user-defined functions.

Views


Citations

23 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. GitHub - cockroachdb/pebble: RocksDB/LevelDB inspired key-value database in Go · GitHub github.com
  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
  21. https://github.com/cockroachdb/cockroach/commit/97f69faeeb79f03456ce976b56cd79f6e5fd386c github.com
  22. https://github.com/cockroachdb/cockroach/commit/b008cc81959aa2b96b045aec4327f061b875ffd1 github.com
  23. https://github.com/cockroachdb/cockroach/commit/4e892582067ad760f67defe4eda86923d4fccf96 github.com
Revision #21 Last Updated: