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.)

Storage Architecture

Disk-oriented

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

Query Compilation

Not Supported

Stored Procedures

Not Supported

Query Interface

SQL

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

Joins

Hash Join

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.

System Architecture

Shared-Nothing

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.

Query Execution

Tuple-at-a-Time Model

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.

Indexes

B+Tree

CockroachDB supports primary key and secondary key indexes using B+Trees. The indexes are implemented with the distributed key-value store ranges.

Storage Model

Custom

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

CockroachDB Logo
Website

https://www.cockroachlabs.com/

Source Code

https://github.com/cockroachdb/cockroach/

Tech Docs

https://www.cockroachlabs.com/docs/stable/

Developer

Cockroach Labs

Country of Origin

US

Start Year

2014

Project Type

Commercial, Open Source

Written in

Go

Supported languages

Go

Embeds / Uses

RocksDB

Inspired By

Cloud Spanner

Compatible With

PostgreSQL

Operating Systems

Linux, OS X, Windows

Licenses

Apache v2

Wikipedia

https://en.wikipedia.org/wiki/Cockroach_Labs