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.

Backend Stop 2 of 2 By UniqBlog Desk 30 November 2026 Updated 1 December 2026 6 min read

Soft 3D illustration: two database cylinders side by side on round pedestals, one blue and one grey, joined by a thin blue route line with a station dot under each

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 jsonb directly; 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:

PostgreSQLCurrent minorFirst releaseEnd of life
1919.02026-11-192031-11-19
1818.72025-09-252030-11-14
1717.122024-09-262029-11-08
1616.162023-09-142028-11-09
1515.202022-10-132027-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?

FeaturePostgreSQL 19MySQL 9.7 LTS
JSONjson and binary jsonb; GIN indexes on whole documents; SQL/JSON pathJSON type; index via generated columns or multi-valued indexes
CTEsYes, including recursiveYes, including recursive
Window functionsYes; 19 adds IGNORE NULLS to lead, lag and friendsYes
UpsertON CONFLICT DO UPDATE / NOTHING, and new DO SELECT in 19ON DUPLICATE KEY UPDATE
ExtensionsCREATE EXTENSION: PostGIS, pgvector, TimescaleDB and many morePlugins and components; smaller third-party ecosystem
ReplicationStreaming (physical) and logical; 19 adds logical replication of sequencesBinary log replication, Group Replication, InnoDB Cluster
Default storageOne engine, MVCC with VACUUMInnoDB (clustered primary key)
LicensePostgreSQL License, BSD/MIT-likeGPLv2 or commercial from Oracle
GovernanceCommunity projectOracle

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?

SituationPick
New product, no existing databasePostgreSQL
Heavy JSON, geo, vector or analytics queriesPostgreSQL
WordPress, Magento or another MySQL-first stackMySQL
Team with deep MySQL operations experienceMySQL
Embedding the database in software you sellPostgreSQL, 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

UniqBlog Desk · Editors

The editors of UniqBlog. Tested tutorials and tech news for working developers.

Further along the line