YugabyteDB — Distributed SQL That Is Fully PostgreSQL Compatible
YugabyteDB is a distributed SQL database that reuses the PostgreSQL query layer while adding horizontal scale, multi-region replication, and resilience. It is Postgres you can shard across continents.
What it is
YugabyteDB is an open-source distributed SQL database that reuses the PostgreSQL query layer -- indexing, extensions, JSONB, stored procedures, triggers -- and places it on top of DocDB, a distributed storage engine forked from RocksDB. The result is a database that behaves exactly like PostgreSQL to your ORM but scales horizontally across zones and regions.
It targets teams running PostgreSQL who have outgrown a single node and need automatic sharding, multi-region replication, and zone-failure resilience without abandoning their existing SQL schemas and tooling.
How it saves time or tokens
Migrating from PostgreSQL to a proprietary distributed database usually means rewriting queries, changing drivers, and learning a new data model. YugabyteDB uses the PostgreSQL wire protocol (YSQL on port 5433), so existing psql commands, pg_dump backups, and ORM configurations work without changes. This eliminates weeks of migration engineering. Automatic sharding removes the manual partition management that PostgreSQL requires at scale.
How to use
- Start a single-node instance with Docker for local development.
docker run -d --name yb \
-p 7000:7000 -p 9000:9000 -p 5433:5433 -p 9042:9042 \
yugabytedb/yugabyte:latest bin/yugabyted start --daemon=false
- Connect using standard psql on port 5433.
psql -h localhost -p 5433 -U yugabyte
- Create tables and run queries exactly as you would in PostgreSQL.
CREATE TABLE orders (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
user_id BIGINT NOT NULL,
amount DECIMAL(18,2),
created TIMESTAMPTZ DEFAULT now()
);
INSERT INTO orders (user_id, amount) VALUES (1, 99.95), (2, 150.00);
SELECT * FROM orders WHERE amount > 100;
Example
A three-node cluster for testing replication:
# Node 1
bin/yugabyted start --base_dir=/tmp/ybd1 --listen=127.0.0.1
# Node 2
bin/yugabyted start --base_dir=/tmp/ybd2 --listen=127.0.0.2 --join=127.0.0.1
# Node 3
bin/yugabyted start --base_dir=/tmp/ybd3 --listen=127.0.0.3 --join=127.0.0.1
Data is automatically sharded across all three nodes. Kill any one node and reads/writes continue on the remaining two.
Related on TokRepo
- Database tools -- Compare YugabyteDB with other database solutions for AI workloads.
- DevOps tools -- Infrastructure automation that pairs well with distributed databases.
Common pitfalls
- YugabyteDB adds network round-trip latency per query compared to single-node PostgreSQL. For low-latency local workloads, vanilla PostgreSQL is faster.
- Not all PostgreSQL extensions are supported. Check the compatibility matrix before migrating extension-heavy schemas.
- Default Docker setup runs a single node without replication. Use at least three nodes for any testing that involves failover behavior.
Frequently Asked Questions
YugabyteDB reuses the PostgreSQL query layer and supports most PostgreSQL syntax, data types, indexing, JSONB, stored procedures, and triggers. Some extensions and advanced features have compatibility gaps. The project maintains a compatibility tracker in its documentation.
YugabyteDB automatically shards data across nodes using hash or range partitioning on the primary key. You do not need to manually define partitions. The system rebalances shards when nodes are added or removed.
Yes. YugabyteDB speaks the PostgreSQL wire protocol on port 5433. Standard drivers for Python (psycopg2), Java (JDBC), Go (pgx), and Node.js (pg) work without modification. ORMs like Django, SQLAlchemy, and GORM connect the same way.
YSQL is the PostgreSQL-compatible SQL API on port 5433. YCQL is a Cassandra-compatible API on port 9042 for wide-column workloads. Most new projects use YSQL for its richer SQL feature set.
Both are distributed SQL databases. YugabyteDB reuses the actual PostgreSQL query layer for higher compatibility, while CockroachDB implements its own SQL engine. YugabyteDB also offers a Cassandra-compatible API (YCQL). Performance and licensing terms differ, so benchmarking your specific workload is recommended.
Citations (3)
- YugabyteDB GitHub— YugabyteDB reuses the PostgreSQL query layer on DocDB storage engine
- YugabyteDB Docs— YSQL provides PostgreSQL wire protocol compatibility
- YugabyteDB Architecture Docs— DocDB is built on a fork of RocksDB
Related on TokRepo
Discussion
Related Assets
Moodle — Open-Source Learning Management System
The most widely used open-source learning platform, providing course management, assessments, and collaboration tools for educators and organizations worldwide.
Sylius — Headless E-Commerce Framework on Symfony
An open-source headless e-commerce platform built on Symfony and API Platform, designed for developers who need a customizable and API-first commerce solution.
Akaunting — Free Self-Hosted Accounting Software
A free, open-source online accounting application built on Laravel for small businesses and freelancers to manage invoices, expenses, and financial reports.