Skip to content

Database Comparison — PostgreSQL vs MySQL vs CockroachDB

Summary

Canonical comparison of the three relational databases covered in this knowledge base: PostgreSQL (single-primary, permissive license, richest SQL and extensions), MySQL (single-primary with built-in Group Replication HA, GPLv2 plus Oracle commercial editions) and CockroachDB (distributed SQL on per-range Raft, PostgreSQL wire protocol, proprietary CockroachDB Software License). Versions and licenses below match the topic pages as of 2026-09-25.

Which One Should I Pick?

Start with the questions below. Most teams land on PostgreSQL. MySQL wins when the estate, tooling or PHP ecosystem already runs on it, and CockroachDB wins when automatic zone or region survival or distributed writes are hard requirements.

flowchart TD
    Q1{"Must writes survive a zone or region<br/>outage with no manual failover,<br/>or scale past one primary?"}
    Q2{"Is a proprietary license<br/>with paid tiers acceptable?"}
    Q3{"Existing MySQL estate, PHP stack<br/>(WordPress, Laravel, Magento)<br/>or Vitess/PlanetScale plans?"}
    Q4{"Need extensions (PostGIS, pgvector,<br/>TimescaleDB) or rich analytical SQL?"}
    CRDB["CockroachDB<br/>(Regular release or CockroachDB Cloud)"]
    OSS["Apache-2.0 distributed SQL<br/>(YugabyteDB, TiDB) or<br/>cloud-native (Spanner, Aurora DSQL)"]
    MY["MySQL 9.7 LTS or 8.4 LTS<br/>(InnoDB Cluster for HA)"]
    PG["PostgreSQL 18<br/>(Patroni, CloudNativePG or managed)"]
    PG2["PostgreSQL 18<br/>(default choice)"]

    Q1 -->|"Yes"| Q2
    Q1 -->|"No"| Q3
    Q2 -->|"Yes"| CRDB
    Q2 -->|"No"| OSS
    Q3 -->|"Yes"| MY
    Q3 -->|"No"| Q4
    Q4 -->|"Yes"| PG
    Q4 -->|"No"| PG2

Quick Reference

Dimension PostgreSQL MySQL CockroachDB
Latest Version 18.6 (2026-08-13). 19 Beta 4 (2026-09-24), GA targeted 2026-10 26.7.0 Innovation (2026-07-28). LTS: 9.7.2 and 8.4.11 (2026-07) v26.2.6 Regular (2026-08-21). v26.3 Innovation (2026-08)
End of life 14 EOL 2026-11-12 8.0 EOL 2026-04-30 (final 8.0.46) v25.2 maintenance ends 2026-12-17
Architecture Single-node (primary + replicas) Single-node (primary + replicas) Distributed (multi-node, symmetric)
Scaling Model Vertical (read replicas for reads) Vertical (read replicas, Group Repl.) Horizontal (automatic sharding)
Default isolation Read Committed Repeatable Read (InnoDB) Serializable (Read Committed GA since v24.1)
Wire Protocol PostgreSQL MySQL PostgreSQL-compatible
License PostgreSQL License (OSI, BSD/MIT-style) GPLv2 Community / commercial Enterprise CockroachDB Software License (proprietary, source-available) since v24.3
Governance PostgreSQL Global Development Group (community) Oracle (advisory steering committee since 2026-06) Cockroach Labs

Feature Matrix

Feature PostgreSQL MySQL CockroachDB
ACID ✅ Full ✅ Full (InnoDB) ✅ Serializable
JSON/Document ✅ JSONB (binary, indexed) ✅ JSON ✅ JSONB (PG compat)
Full-text search ✅ Built-in ✅ Built-in ⚠️ Basic
Geo/Spatial ✅ PostGIS ✅ Spatial ✅ Built-in
Vector search ✅ pgvector extension ⚠️ VECTOR type since 9.0. DISTANCE() only in HeatWave / MySQL AI (Percona Server 9.7.2-2 adds its own) ✅ VECTOR type (v24.2) and CREATE VECTOR INDEX (GA v25.4)
Async I/O subsystem ✅ PG 18 AIO (worker default, io_uring on Linux), reads only Not covered on the topic page Not covered on the topic page
Horizontal write scaling ❌ (Citus extension) ❌ (Group Repl. limited) ✅ Native
Multi-region active-active ❌ ❌ ✅ Native
Automatic failover ⚠️ External (Patroni, CloudNativePG, managed service) ⚠️ Built in within a Group Replication group. ClusterSet cross-site failover is operator-initiated ✅ Automatic, including zone or region loss when configured
Online DDL ⚠️ (some locking) ✅ (InnoDB online DDL) ✅ Non-blocking online schema changes
Logical replication / CDC ✅ (parallel apply and conflict logging in v18) ✅ (binlog, Debezium CDC) ✅ Changefeeds (CDC), LDR active-active (GA v25.2)
Extensions ✅ Rich (PostGIS, TimescaleDB, and others) ⚠️ Limited (plugins and components) ❌ (spatial types built in instead)

Performance Positioning

Positioning below is qualitative. No controlled cross-engine benchmark is recorded in this vault, so benchmark your own workload.

Workload Best Choice
Single-node OLTP PostgreSQL or MySQL. Both are strong. Small-transaction commit latency is bound by WAL/redo flush, which PG 18 AIO does not change
Scan-heavy reads on cloud block storage PostgreSQL 18 (AIO speeds up sequential and bitmap heap scans and VACUUM. PGDG reports up to 3x faster reads in its tests)
Single-node mixed OLTP+OLAP MySQL HeatWave (if Oracle OK)
Read-heavy, many replicas PostgreSQL or MySQL
Write-heavy, global distribution CockroachDB
Multi-region, data sovereignty CockroachDB
AI/vector search PostgreSQL (pgvector) or CockroachDB (built-in vector index). MySQL Community lacks DISTANCE()

Decision Guide

Scenario Recommendation
General-purpose backend PostgreSQL — most features, most extensions
WordPress / PHP ecosystem MySQL — deepest PHP/Laravel integration
Global application, multi-region CockroachDB — survive anything
Lowest single-region latency per query PostgreSQL or MySQL on one primary (no Raft quorum per write)
Combined OLTP + analytics MySQL HeatWave (managed) or PG + TimescaleDB
Regulatory data sovereignty CockroachDB — geo-partitioned data
Budget-conscious, open-source PostgreSQL (most permissive license). CockroachDB is not open source since v24.3
Existing MySQL workloads MySQL 9.7 LTS (or stay on 8.4 LTS, supported to 2032). Still on 8.0 (EOL)? Upgrade to 8.4 first, since there is no direct 8.0 to 9.x path

Replication Models

PostgreSQL — WAL Streaming Replication

PostgreSQL uses a primary-standby architecture with Write-Ahead Log (WAL) streaming. There is no distributed consensus protocol — the primary is the single authoritative source.

  • Mechanism: Every write is first recorded in the WAL. The WAL sender process on the primary streams WAL records to the WAL receiver process on each standby in near-real-time
  • Topology: 1:N (one primary, multiple standbys). Supports cascading replication (standby ships WAL to another standby)
  • Sync modes: Asynchronous by default. Synchronous mode available via synchronous_standby_names — each commit waits for standby confirmation before returning to the client
  • Logical replication: Supported since v10. Allows selective table replication, cross-version replication, and pub/sub patterns. v18 adds parallel streaming by default and conflict logging. v19 (beta) adds sequence replication
  • Failover: Requires external tools — Patroni, pg_auto_failover, CloudNativePG (Kubernetes) or a managed service. No built-in automatic failover

MySQL — Group Replication (Paxos / XCom)

MySQL offers traditional async replication plus Group Replication (GR), which uses a Paxos-based consensus protocol called XCom (a Mencius variant).

  • Consensus: Transactions are broadcast to all group members via XCom. Each member independently certifies the transaction by checking for write-set conflicts. Since certification is deterministic, all members make the same commit/abort decision
  • Group size: up to 9 members
  • Single-Primary mode (default): One member accepts writes. The others are read-only. Automatic leader election on primary failure
  • Multi-Primary mode: All members accept writes simultaneously. Write conflicts are detected and one transaction is rolled back
  • Fault tolerance: Requires n = 2f + 1 members to tolerate f failures. A 3-node group tolerates 1 failure. A 5-node group tolerates 2
  • Single consensus leader: MySQL 8.0.27+ supports group_replication_paxos_single_leader for improved throughput in single-primary mode
  • Semi-sync replication: Alternative to GR — primary waits for at least one replica to acknowledge before returning to client. Simpler than GR but no automatic failover

CockroachDB — Raft Consensus (Per-Range)

CockroachDB is natively distributed. Data is split into ranges (up to 512 MiB by default), and each range is replicated via the Raft consensus protocol (3 replicas by default, 5 for system ranges).

  • Raft groups: Each range has its own independent Raft group with a leader, followers, and a log. The leader coordinates writes. A majority quorum must acknowledge before commit
  • Lease-holder: One replica per range is the "lease-holder" that coordinates reads and writes. Since v25.2 (leader leases) the leaseholder is always the Raft leader
  • Automatic rebalancing: If a node fails, CockroachDB automatically re-replicates under-replicated ranges to other nodes
  • Hybrid Logical Clocks (HLC): CockroachDB uses HLC timestamps to order transactions across nodes. Together with MVCC this enables serializable distributed transactions
  • No external tools: Failover, rebalancing, and replication are all built into the database — no Patroni, no ProxySQL, no manual intervention

Replication Comparison Matrix

Dimension PostgreSQL MySQL (Group Repl.) CockroachDB
Protocol WAL streaming (no consensus) Paxos variant (XCom) Raft (per-range)
Write path Single primary only Single or multi-primary Any node (lease-holder per range)
Consensus required No (primary is authoritative) Yes (majority quorum) Yes (majority quorum per range)
Automatic failover No (needs Patroni and others) Yes (within group) Yes (built-in)
Replication lag Seconds (async) / zero (sync) Near-zero (virtually synchronous) None for committed writes (quorum-acknowledged). Follower reads are bounded-stale
Max replicas No hard limit (typical: 2-5) 9 members per group num_replicas per zone config (default 3, 5 for system ranges; 5 voters with SURVIVE REGION FAILURE)
Cross-region Possible but high-latency sync Possible (InnoDB ClusterSet) Native (geo-partitioned)

Consistency Trade-offs

CAP Theorem Positioning

The diagram places each engine by its default deployment. "CA" only describes a single node that has no partition to tolerate. Once replicas are added, each engine must choose consistency or availability during a partition.

graph TD
    subgraph CAPPOS["CAP positioning"]
        CP["CP systems<br/>(Consistency + Partition tolerance)"]
        CA["CA only on a single node<br/>(no partition to tolerate)"]
    end

    PG["PostgreSQL<br/>(single node: CA<br/>sync replication: CP)"] --> CA
    MY["MySQL<br/>(single node: CA<br/>Group Replication: CP)"] --> CA
    CRDB["CockroachDB<br/>(CP: consistent,<br/>available while a majority is up)"] --> CP
Database CAP Position Consistency Model During Partition
PostgreSQL CA (single-node). CP (sync repl.) Strong on single node Primary continues. Standbys can lag or disconnect
MySQL CA (single-node). CP (Group Repl.) Strong on single node GR blocks writes if no quorum
CockroachDB CP Serializable by default (distributed) Ranges that lose quorum become unavailable. Ranges with a majority continue

Isolation Levels

Level PostgreSQL MySQL (InnoDB) CockroachDB
Read Uncommitted Treated as Read Committed Supported Upgraded to Read Committed
Read Committed Default Supported Supported (GA since v24.1)
Repeatable Read Supported (snapshot isolation) Default Not a distinct level (mapped to Serializable)
Serializable Supported (SSI) Supported (locking reads) Default

CockroachDB defaults to Serializable

CockroachDB runs SERIALIZABLE by default. READ COMMITTED is GA since v24.1 and is opt-in per session or transaction. CockroachDB's Read Committed is stronger than PostgreSQL's (no intra-statement anomalies, no retry errors). PostgreSQL defaults to Read Committed and needs an explicit SET TRANSACTION ISOLATION LEVEL SERIALIZABLE. MySQL InnoDB defaults to Repeatable Read with next-key (gap) locking.

Anomaly Handling

Anomaly PostgreSQL MySQL CockroachDB
Dirty reads Prevented (all levels) Possible at Read Uncommitted Prevented (all levels)
Non-repeatable reads Prevented at RR+ Prevented at RR+ Prevented at Serializable. Possible across statements at Read Committed
Phantom reads Prevented at RR+ (snapshot) Prevented at RR for locking reads (gap locks) Prevented at Serializable
Write skew Prevented at Serializable (SSI) Possible at RR. Prevented at Serializable Prevented at Serializable (default)

Migration Paths

MySQL to PostgreSQL

The most common migration path. Key tools and considerations:

Tool Type Best For Throughput
pgLoader Open-source CLI One-time "big bang" migrations Up to 3 TB/hr (tuned)
AWS DMS Managed service Continuous replication / zero-downtime cutover Varies by instance class
Ora2Pg Open-source CLI Oracle-to-PG (also handles MySQL) Medium

Common pitfalls:

  • ENUM types map differently (MySQL ENUM to PG ENUM or VARCHAR)
  • AUTO_INCREMENT maps to SERIAL / IDENTITY
  • MySQL's TINYINT(1) for booleans needs mapping to PG BOOLEAN
  • Case sensitivity: MySQL defaults to case-insensitive collation. PG is case-sensitive
  • Stored procedures require manual rewrite (MySQL procedural SQL differs significantly from PL/pgSQL)

PostgreSQL to CockroachDB

CockroachDB's PostgreSQL wire compatibility makes this the smoothest distributed migration path.

Tool Purpose
MOLT SCT (Schema Conversion Tool) Converts PG schema to CockroachDB-compatible DDL
MOLT Fetch Migrates data from PG to CockroachDB
MOLT Verify Validates data integrity post-migration (table, column, row verification)
MOLT Replicator Continuous replication for a minimal-downtime cutover
AWS DMS Alternative: configure CockroachDB as PG target endpoint

Key constraints:

  • All tables must have explicit primary keys (CockroachDB requirement)
  • PG extensions cannot be loaded (spatial types are built in instead of PostGIS; no TimescaleDB, no pg_cron)
  • Prefer UUID keys (or hash-sharded indexes) over sequential SERIAL keys to avoid write hotspots
  • ORM compatibility: most PG-compatible ORMs work unchanged. Test with your specific ORM version

MySQL to CockroachDB

No direct migration path. The recommended approach:

  1. MySQL to PostgreSQL (via pgLoader or DMS)
  2. PostgreSQL to CockroachDB (via MOLT tooling)

Alternatively, use AWS DMS directly — configure MySQL as source, CockroachDB (via PG endpoint) as target.

Managed Service Options

Prices and SLAs are estimates

Checked 2026-09-28. Vendor pages: the Google Cloud rows against Google's SLA and pricing pages, the CockroachDB rows against the CockroachDB Cloud docs, and the AWS, Azure, Neon and Supabase SLAs, the Neon and Supabase free plans, and PlanetScale's entry prices and storage rate against the vendors' own SLA, docs and pricing pages (via search listing; see Sources). Third-party price trackers: the RDS instance and Azure Burstable prices come from Bytebase's RDS and Azure flexible server price tables and Vantage, and the RDS and Aurora storage rates from the same trackers and CloudZero's Aurora guide. The PlanetScale SLA is as summarised by DevHelm (see Sources). Cloud pricing changes often, so check each vendor's pricing page before quoting.

Service Engine Provider Min Price HA Model SLA
RDS for PostgreSQL PostgreSQL AWS ~$12/mo compute (db.t4g.micro at $0.016/h, Single-AZ, us-east-1; storage extra) Multi-AZ standby 99.95% (Multi-AZ instances and clusters)
RDS for MySQL MySQL AWS ~$12/mo compute (db.t4g.micro, Single-AZ, us-east-1; storage extra) Multi-AZ standby 99.95%
Aurora PostgreSQL PG-compatible AWS Serverless v2 scales to 0 ACU with auto-pause (since 2024-11-20); storage only while paused 6-way storage replication 99.99% (Multi-AZ)
Aurora MySQL MySQL-compatible AWS Serverless v2 scales to 0 ACU with auto-pause (Aurora MySQL 3.08+) 6-way storage replication 99.99% (Multi-AZ)
Cloud SQL PG / MySQL GCP ~$8/mo compute (db-f1-micro shared-core, $0.0105/h; no SLA) Regional HA 99.95% (Enterprise with HA), 99.99% (Enterprise Plus with HA)
AlloyDB PG-compatible GCP $0.06608 per vCPU-hour plus $0.0112 per GiB-hour of memory (us-central1 list price), plus storage; roughly $48/mo per vCPU and $8/mo per GiB of memory Disaggregated compute/storage 99.99% with HA (99.95% in Mexico and Stockholm)
CockroachDB Cloud Basic / Standard CockroachDB Cockroach Labs Basic: $0.20 per 1M Request Units and $0.50 per GiB storage, first $15/month free on monthly billing. Standard: per provisioned vCPU-hour (doc example about $0.10 to $0.12 on GCP) Multi-AZ by default See the Technical SLA (per-plan figures not reachable from this environment, 2026-09-28)
CockroachDB Cloud Advanced CockroachDB Cockroach Labs Per node-hour by machine size, cloud and region (doc example: $1.062/h for 8 vCPU / 32 GiB on GCP us-west1) Dedicated clusters, multi-AZ / multi-region Up to 99.999% (multi-region)
Aurora DSQL PG-compatible distributed SQL AWS Pay per DPU and storage (free tier 100K DPUs + 1 GB/month) Active-active, multi-Region 99.99% single-Region, 99.999% multi-Region (design target)
PlanetScale MySQL (Vitess) / PostgreSQL PlanetScale No free tier since 2024-04. From $39/mo (Vitess MySQL PS-10, 3-node HA) and $5/mo (PS-5 single-node Postgres) 3 nodes across AZs 99.99% single-region, 99.999% multi-region
Azure Database PG / MySQL Azure ~$12/mo (Burstable B1ms compute; zone-redundant HA bills a standby too) Zone-redundant HA Up to 99.99% (zone-redundant HA)
Neon PostgreSQL Neon Free (0.5 GB storage per project) Serverless, auto-scale 99.95% (Business and Scale compute endpoints)
Supabase PostgreSQL Supabase Free (500 MB database, 2 projects; pauses after a week idle) Single-node (Pro: HA) 99.9% (Enterprise subscriptions only)

Key Differentiators

Capability RDS Aurora Cloud SQL AlloyDB CockroachDB Cloud PlanetScale
Serverless No Yes (Serverless v2) No No Yes (Basic plan) No
Multi-region active-active No Aurora DSQL (GA 2025-05-27) No No Yes (native) No
Online DDL Engine-dependent Engine-dependent Engine-dependent Yes Yes (zero-downtime) Yes (non-blocking)
Branching No No No No No Yes
Storage pricing (US list price, 2026-09) ~$0.12/GB-mo (gp3 $0.115) ~$0.10/GB-mo ~$0.17/GiB-mo SSD ($0.000232877/GiB-h) ~$0.30/GiB-mo ($0.0004109/GiB-h regional cluster storage) Basic $0.50/GiB-mo; Standard and Advanced per GiB-hour by cloud and region $0.50/GB-mo beyond 10 GB included

Storage costs vary dramatically

Distributed and developer-platform services (PlanetScale, CockroachDB Cloud Basic) charge several times more per GB than RDS-style services. This is partly offset by built-in HA (no separate standby to pay for), but it can be surprising at multi-TB scale.

Total Cost of Ownership

Licensing

Database License Commercial Restrictions
PostgreSQL PostgreSQL License (MIT-like) None — fully permissive
MySQL GPL 2.0 / Commercial (Oracle) GPL copyleft for linked applications. A commercial license is available
CockroachDB CockroachDB Software License (proprietary, since v24.3, 2024-11-18). Previously BSL 1.1 core + CCL Multi-node self-hosted clusters need a license key: paid Enterprise, Enterprise Free (under $10M annual revenue, telemetry required) or 30-day Trial. No key: single-node dev only. Offering it as a service to third parties needs a license

Self-Hosted Cost Comparison (AWS, 3-year reserved)

Rough infrastructure-only estimates (compute and storage, no license fees). They are illustrative and not sourced to a pricing calculator. CockroachDB license cost is extra for organizations above the Enterprise Free threshold.

Scale PostgreSQL MySQL CockroachDB
Small (2 vCPU, 8 GB, 100 GB) ~$120/mo (1 primary + 1 standby) ~$120/mo (1 primary + 1 replica) ~$360/mo (3-node cluster minimum)
Medium (8 vCPU, 32 GB, 1 TB) ~$600/mo (1 primary + 2 standbys) ~$600/mo (1 primary + 2 replicas) ~$1,200/mo (3-node cluster)
Large (32 vCPU, 128 GB, 10 TB) ~$3,000/mo (1 primary + 3 standbys) ~$3,000/mo (1 primary + 3 replicas) ~$4,500/mo (5-node cluster)

Operational Overhead

Dimension PostgreSQL MySQL CockroachDB
DBA skill availability High (large talent pool) High (largest talent pool) Low (specialized skill)
Failover management Patroni, pg_auto_failover or CloudNativePG Group Replication / InnoDB Cluster (MySQL Router routes clients) Automatic (built-in)
Backup tooling pg_dump, pgBackRest, Barman mysqldump, MySQL Shell dump utilities, Percona XtraBackup, MySQL Enterprise Backup Built-in backup to cloud storage
Monitoring pg_stat_*, pgBadger, Datadog Performance Schema, PMM, Datadog DB Console (built-in), Datadog
Schema migrations Flyway, Alembic, golang-migrate Flyway, Liquibase, gh-ost Flyway, MOLT SCT
Estimated DBA FTE (rough estimate, unsourced) 0.25-0.5 per cluster 0.25-0.5 per cluster 0.1-0.25 per cluster

CockroachDB trades higher infra cost for lower ops cost

CockroachDB needs a 3-node minimum for HA, but removes external failover tools and manual shard management. For globally distributed applications the operational savings can exceed the infrastructure and license premium. For single-region applications they usually do not.

Decision Framework by Annual Budget

Budget Recommended Path
< $5K/yr PostgreSQL or MySQL on a single VPS + automated backups
$5K-25K/yr Managed PostgreSQL (RDS, Cloud SQL, Neon) or managed MySQL (RDS, PlanetScale)
$25K-100K/yr Aurora PostgreSQL or AlloyDB for performance. CockroachDB Cloud Basic/Standard for distribution
$100K+/yr CockroachDB Cloud Advanced or self-hosted Enterprise for global active-active. Aurora DSQL for AWS-native multi-region

Sources

See Also