PostgreSQL vs MySQL in 2026: which database should you pick?
PostgreSQL vs MySQL compared on current versions: JSON, CTEs, window functions, extensions, replication, licensing and cost, with SQL we ran on both.
For a new application with no constraints, pick PostgreSQL: it has the richer SQL, the better JSON indexing, a large extension ecosystem and a permissive license. Pick MySQL when your team, hosting platform or software stack already runs on it, or when you need its mature, simple primary-replica replication. Both handle CTEs, window functions and serious production load.
Key takeaways
- Current versions as of December 2026: PostgreSQL 19.0 (released 2026-11-19) and MySQL 9.7 LTS (latest 9.7.4.1), with MySQL 26.10 on the Innovation track.
- Standard SQL such as CTEs and window functions ran unchanged on both in our test.
- JSON is where they differ most: PostgreSQL indexes
jsonbdirectly; MySQL indexes JSON through generated columns. - Both are free to run. Licensing differs if you embed and distribute the database: PostgreSQL License versus GPLv2 or a commercial license from Oracle.
Which versions are current, and how long are they supported?
PostgreSQL ships one major version a year and supports each for five years:
| PostgreSQL | Current minor | First release | End of life |
|---|---|---|---|
| 19 | 19.0 | 2026-11-19 | 2031-11-19 |
| 18 | 18.7 | 2025-09-25 | 2030-11-14 |
| 17 | 17.12 | 2024-09-26 | 2029-11-08 |
| 16 | 16.16 | 2023-09-14 | 2028-11-09 |
| 15 | 15.20 | 2022-10-13 | 2027-11-11 |
MySQL has two tracks. LTS releases get five years of premier plus three years of extended support and only receive fixes: 8.4 and 9.7 are the current LTS lines, and 9.7.0 shipped on 2026-04-21. Innovation releases add features and are supported only until the next one. After 9.7, Oracle moved Innovation releases to calendar versions: 26.7 in July and 26.10 on 2026-10-20. For production, use an LTS line.
What are the main differences between PostgreSQL and MySQL?
| Feature | PostgreSQL 19 | MySQL 9.7 LTS |
|---|---|---|
| JSON | json and binary jsonb; GIN indexes on whole documents; SQL/JSON path | JSON type; index via generated columns or multi-valued indexes |
| CTEs | Yes, including recursive | Yes, including recursive |
| Window functions | Yes; 19 adds IGNORE NULLS to lead, lag and friends | Yes |
| Upsert | ON CONFLICT DO UPDATE / NOTHING, and new DO SELECT in 19 | ON DUPLICATE KEY UPDATE |
| Extensions | CREATE EXTENSION: PostGIS, pgvector, TimescaleDB and many more | Plugins and components; smaller third-party ecosystem |
| Replication | Streaming (physical) and logical; 19 adds logical replication of sequences | Binary log replication, Group Replication, InnoDB Cluster |
| Default storage | One engine, MVCC with VACUUM | InnoDB (clustered primary key) |
| License | PostgreSQL License, BSD/MIT-like | GPLv2 or commercial from Oracle |
| Governance | Community project | Oracle |
The PostgreSQL 19 release also brings REPACK (CONCURRENTLY) to reclaim table space without blocking reads or writes, WAIT FOR LSN for read-your-writes on standbys, and faster foreign key checks.
Which is better for complex queries?
For everyday analytics SQL, the two now look alike. We ran this query, a CTE wrapping two window functions, on PostgreSQL 19.0 and MySQL 9.7.4 in throwaway Docker containers. It ran unchanged on both:
CREATE TABLE orders (
id INT PRIMARY KEY,
customer VARCHAR(40) NOT NULL,
placed_on DATE NOT NULL,
total DECIMAL(10,2) NOT NULL,
meta JSON NOT NULL
);
INSERT INTO orders VALUES
(1, 'ada', '2026-11-02', 40.00, '{"channel": "web", "coupon": null}'),
(2, 'ada', '2026-11-09', 120.00, '{"channel": "mobile", "coupon": "BF26"}'),
(3, 'grace', '2026-11-03', 75.50, '{"channel": "web", "coupon": "BF26"}'),
(4, 'grace', '2026-11-20', 20.00, '{"channel": "web", "coupon": null}'),
(5, 'linus', '2026-11-15', 300.00, '{"channel": "mobile", "coupon": null}');
WITH per_customer AS (
SELECT customer, placed_on, total,
SUM(total) OVER (PARTITION BY customer ORDER BY placed_on) AS running_total,
RANK() OVER (ORDER BY total DESC) AS size_rank
FROM orders
)
SELECT * FROM per_customer ORDER BY customer, placed_on;
Both returned the same five rows:
customer | placed_on | total | running_total | size_rank
----------+------------+--------+---------------+-----------
ada | 2026-11-02 | 40.00 | 40.00 | 4
ada | 2026-11-09 | 120.00 | 160.00 | 2
grace | 2026-11-03 | 75.50 | 75.50 | 3
grace | 2026-11-20 | 20.00 | 95.50 | 5
linus | 2026-11-15 | 300.00 | 300.00 | 1
JSON is where the dialects split. PostgreSQL indexes the whole document and queries it by containment:
-- PostgreSQL
ALTER TABLE orders ALTER COLUMN meta TYPE jsonb USING meta::jsonb;
CREATE INDEX orders_meta_gin ON orders USING gin (meta);
SELECT meta->>'channel' AS channel, count(*), sum(total)
FROM orders
WHERE meta @> '{"coupon": "BF26"}'
GROUP BY 1;
MySQL indexes one path at a time through a generated column. EXPLAIN confirmed the lookup used the index:
-- MySQL
ALTER TABLE orders
ADD COLUMN coupon VARCHAR(20)
GENERATED ALWAYS AS (meta->>'$.coupon') VIRTUAL,
ADD INDEX orders_coupon (coupon);
SELECT meta->>'$.channel' AS channel, count(*), sum(total)
FROM orders
WHERE coupon = 'BF26'
GROUP BY 1;
Both returned mobile 1 120.00 and web 1 75.50. One trap showed up on MySQL: for a JSON null, ->> returns the four-character string 'null', not SQL NULL. In our table SUM(coupon IS NULL) was 0 and SUM(coupon = 'null') was 3. Filter with that in mind.
PostgreSQL 19's new upsert form returns the existing row on conflict, the "get or create" pattern in one statement:
CREATE TABLE tags (id serial PRIMARY KEY, name text UNIQUE NOT NULL);
INSERT INTO tags (name) VALUES ('postgres');
INSERT INTO tags (name) VALUES ('postgres'), ('mysql')
ON CONFLICT (name) DO SELECT
RETURNING id, name;
-- id | name
-- ----+----------
-- 1 | postgres
-- 3 | mysql
Note the id of 3: the conflicting row still consumed a sequence value.
Which scales better?
Both scale vertically to large single machines, and both scale reads with replicas. The differences are in the tooling around them:
- MySQL has a long record of large read-heavy web deployments, built-in Group Replication and InnoDB Cluster for failover, and sharding layers such as Vitess.
- PostgreSQL offers physical streaming replicas and flexible logical replication. Horizontal sharding comes from extensions such as Citus, not the core.
- Write scaling beyond one primary is hard on both. Plan with partitioning, caching and queueing before you plan for multi-primary.
At scale, operational habits matter more than the engine. PostgreSQL needs healthy autovacuum. MySQL needs care with replication lag and schema changes on big tables.
How do they affect development speed and cost?
Day-one speed is a wash: every mainstream ORM and framework supports both, and managed versions exist on every major cloud. The differences show up later:
- Strictness. PostgreSQL's type system is strict and has few switches. MySQL's handling of invalid or truncated data depends on
sql_mode, so check what your managed host sets. - One database for more jobs. With PostgreSQL extensions (pgvector for embeddings, PostGIS for geo), teams often skip running a second datastore.
- Hosting cost. Both engines are free. Managed-service prices depend on instance size and storage rather than on which engine you choose, so compare actual quotes.
- License cost. It only matters if you distribute the database inside a proprietary product. MySQL's GPLv2 may then require a commercial license from Oracle; the PostgreSQL License does not.
So which should you choose?
| Situation | Pick |
|---|---|
| New product, no existing database | PostgreSQL |
| Heavy JSON, geo, vector or analytics queries | PostgreSQL |
| WordPress, Magento or another MySQL-first stack | MySQL |
| Team with deep MySQL operations experience | MySQL |
| Embedding the database in software you sell | PostgreSQL, or budget for a MySQL commercial license |
Whichever you choose, run a supported version: PostgreSQL 18 or 19, MySQL 8.4 or 9.7 LTS.
Sources
Transfer to
UniqBlog Desk · Editors
The editors of UniqBlog. Tested tutorials and tech news for working developers.
Further along the line

Secrets management across environments: a practical ladder
A secrets management ladder for dev, staging and prod: from .env files to SOPS and age, cloud secret managers, Vault or OpenBao, and External Secrets Operator.

Kubernetes vs Docker: which one do you actually need?
Kubernetes vs Docker is not either-or: Docker builds and runs containers, Kubernetes schedules them across machines. Here is when each layer earns its cost.

Docker Compose volumes: bind mounts, tmpfs and backups
Docker Compose volumes explained with a tested compose file: when to use named volumes, bind mounts or tmpfs, how to name them, and how to back up and restore one.

Git rebase vs merge: when to use each, with a demo
Git rebase vs merge with a reproducible demo: how each shapes history, when to rebase, the golden rule, safe force-pushes, and git pull vs fetch.