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][03]
- Country of Origin
- US
- Project Types
- Commercial, Open Source
- Supported Languages
- Go
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][03]
History[04][05][06]
CockroachDB is inspired by Google’s Spanner and F1 to address fault tolerance and distributed consistency.
Indexes[08][09][10]
CockroachDB supports primary key, secondary index. The indexes are implemented with the distributed key-value store ranges.
Isolation Levels[03][11][12]
CockroachDB supports snapshot isolation (SI) and serializable snapshot isolation (SSI). It is implemented using RocksDB snapshot capability.
Joins[13]
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[03]
There's no logging in CockroachDB because it adopts MVCC and uses transaction table to control transactions.
Query Execution[14]
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[15]
CockroachDB aims to provide standard SQL with extensions, but some standard SQL functionality is under development.
Storage Architecture[03]
The backend storage in CockroachDB is RocksDB. It is disk-oriented storage.
System Architecture[03]
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.
Citations
18 sources- CockroachDB | Distributed SQL for always-on customer experiences cockroachlabs.com
- GitHub - cockroachdb/cockroach: CockroachDB — the cloud native, distributed SQL database designed for high availability, effortless scale, and control over data placement. · GitHub github.com
- cockroach/docs/design.md at master · cockroachdb/cockroach · GitHub github.com
- CockroachDB FAQs cockroachlabs.com
- Spanner: Google’s Globally-Distributed Database | USENIX usenix.org
- F1 - The Fault-Tolerant Distributed RDBMS Supporting Google's Ad Business research.google
- FKs RFC by dt · Pull Request #6309 · cockroachdb/cockroach · GitHub github.com
- https://pkg.go.dev/github.com/cockroachdb/cockroach/sql?utm_source=godoc go.dev
- https://github.com/cockroachdb/cockroach/blob/master/storage/scanner_test.go github.com
- SQL in CockroachDB: Mapping table data to key-value storage cockroachlabs.com
- cockroach/storage/replica_raftstorage.go at 266e50907fbc7b0769ab6afd10892b16cc02c371 · cockroachdb/cockroach · GitHub github.com
- cockroach/storage/engine/rocksdb.go at 5c4631f4b7328764ab150938974766d7e63c746a · cockroachdb/cockroach · GitHub github.com
- https://github.com/cockroachdb/cockroach/blob/master/docs/RFCS/distributed_sql.md github.com
- https://github.com/cockroachdb/cockroach/blob/master/docs/RFCS/distributed_sql.md#execution-infrastructure github.com
- https://www.cockroachlabs.com/docs/learn-cockroachdb-sql.html cockroachlabs.com
- https://pkg.go.dev/github.com/cockroachdb/cockroach/storage?utm_source=godoc go.dev
- About cockroachlabs.com
- https://twitter.com/cockroachdb twitter.com