CockroachDB

active

by Cockroach Labs · since 2015 · also known as CRDB, Cockroach

Postgres-wire distributed SQL built to survive node, zone and region failures with serializable transactions.

relationaldocumentspatialvectordatabase enginesource-availablemature

Overview

CockroachDB is a distributed SQL database that shards data into Raft-replicated ranges and runs serializable ACID transactions across them, so a cluster keeps accepting reads and writes through node, zone or region loss. It speaks the PostgreSQL wire protocol and much of its dialect, and adds multi-region table locality controls that pin rows to geographies for latency or data residency. It is a strong fit for globally distributed OLTP systems of record such as payments, identity and inventory. Since late 2024 every self-hosted binary ships under the proprietary CockroachDB Software License, free only for individuals and smaller companies, so budget for an enterprise contract at scale.

Strengths & trade-offs

Strengths

  • +Serializable isolation by default across shards, with no application-level sharding
  • +Survives zone or region loss without manual failover thanks to Raft replication
  • +Row-level geo-partitioning (REGIONAL BY ROW) for data residency and local-latency writes
  • +PostgreSQL wire compatibility lets most Postgres drivers and ORMs connect unchanged
  • +Online schema changes and rolling upgrades without downtime
  • +Changefeeds stream row changes to Kafka, cloud storage or webhooks

Trade-offs

  • −Self-hosted use now requires a proprietary license; larger companies must pay
  • −Single-row write latency is higher than a single-node Postgres because of consensus
  • −Not a drop-in Postgres: many extensions (PostGIS internals, pg_cron, etc.) are unavailable
  • −Serializable retries (40001 errors) must be handled in application code
  • −Analytical queries over large scans are slow compared with columnar engines

Great for

  • +Global payments and ledger systems of record
  • +Identity, account and session metadata across regions
  • +Inventory and order management with strict consistency
  • +Data-residency workloads that must pin rows to a country
  • +Replacing hand-sharded Postgres or MySQL fleets

Think twice for

  • −Heavy analytics or data warehousing
  • −Workloads relying on niche Postgres extensions
  • −Tiny apps where a single Postgres instance suffices
  • −Teams that need a permissive open-source license

Capabilities

Native or official first-party support · 18 of 25 tracked

✓Transactions
✓Joins
✓Secondary indexes
✓Full-text search
✓Vector search
✓Geospatial
✓JSON
✓Change data capture
✓Triggers
✓Stored procedures
✓Materialized views
✓TTL / expiry
✓Durable persistence
✓Compression
✓Encryption at rest
✓Role-based access
✓Time travel
✓Online schema changes
–Pub/Sub
–Columnar storage
–In-memory
–Branching
–Streaming ingest
–Offline sync
–Runs in WebAssembly

Scale & consistency

Comfortable data size
Large · ≤ 1 PB
Horizontal scaling
Native
Multi-region
Active active
Transactions
Full ACID
Consistency
Strong
Schema
Strict
Architecture
Distributed, Multi primary, Client server, Serverless
Query languages
SQL, PL/pgSQL

Automatic range splitting and rebalancing; REGIONAL BY ROW and GLOBAL tables control write latency vs. read locality across regions.

Deployment

Self-hosted Vendor-managed cloud Serverless Embedded Edge Kubernetes operator

available on · AWS · Google Cloud · Azure

Ecosystem

compatible withPostgreSQL
apis & protocolsPostgreSQL wire protocol, HTTP SQL API (Cloud)
client languagesJava, Go, Python, JavaScript, C#, Ruby, Rust, PHP
used byNetflix, DoorDash

Alternatives to CockroachDB

Compare all→
YugabyteDBRelational32.7

Apache-licensed distributed SQL that reuses the PostgreSQL query layer on a Raft-replicated storage engine.

cockroachdb vs yugabytedb →
Google Cloud SpannerRelational34.5

Google's globally consistent, horizontally scaling SQL service with graph, vector and full-text built in.

cockroachdb vs google-cloud-spanner →
TiDBRelational35.9

MySQL-compatible distributed SQL with a row store for OLTP and a columnar replica for real-time analytics.

cockroachdb vs tidb →
Amazon Aurora DSQLRelational14.7

Serverless, active-active distributed SQL on AWS with PostgreSQL compatibility and no instances to size.

cockroachdb vs amazon-aurora-dsql →
PostgreSQLRelational93.2

The extensible, standards-first open-source relational database.

cockroachdb vs postgresql →
pgEdgeRelational10.1

Fully open-source multi-master distributed PostgreSQL built on the Spock logical replication extension.

cockroachdb vs pgedge →

CockroachDB FAQ

What is CockroachDB?

CockroachDB is a relational database by Cockroach Labs, first released in 2015. CockroachDB is a distributed SQL database that shards data into Raft-replicated ranges and runs serializable ACID transactions across them, so a cluster keeps accepting reads and writes through node, zone or region loss. It speaks the PostgreSQL wire protocol and much of its dialect, and adds multi-region table locality controls that pin rows to geographies for latency or data residency. It is a strong fit for globally distributed OLTP systems of record such as payments, identity and inventory. Since late 2024 every self-hosted binary ships under the proprietary CockroachDB Software License, free only for individuals and smaller companies, so budget for an enterprise contract at scale.

Is CockroachDB open source?

Not in the OSI sense. CockroachDB is source-available: you can read the code, but the license restricts some uses, typically offering it as a competing managed service. License: CockroachDB Software License.

Does CockroachDB support ACID transactions?

Yes. CockroachDB supports full ACID transactions, with strong consistency.

Does CockroachDB scale horizontally?

CockroachDB scales horizontally out of the box, with built-in sharding or partitioning. It is comfortable at large scale (≤ 1 PB). It supports active-active multi-region writes.

How can I run CockroachDB?

You can self-host it, use the vendor's managed cloud and run it serverless. Managed offerings include CockroachDB Cloud. It is available on AWS, Google Cloud and Azure.

What is CockroachDB best for?

CockroachDB is a strong fit for global payments and ledger systems of record; identity, account and session metadata across regions; and inventory and order management with strict consistency. Think twice for heavy analytics or data warehousing.

What are the best alternatives to CockroachDB?

Common alternatives to CockroachDB include YugabyteDB, Google Cloud Spanner, TiDB, Amazon Aurora DSQL and PostgreSQL. The right choice depends on your workload, scale and hosting; WhichDB's smart match ranks them against your requirements.

How popular is CockroachDB?

CockroachDB ranks #33 of 844 databases on the WhichDB Score (47.1/100), and #10 among relational databases. The score combines public adoption signals such as package downloads, GitHub activity, job posts and developer discussion.