MySQL versus PostgreSQL

Both are mature, fast and free, and both run huge production systems. The choice usually comes down to the features your application needs, the tools your team knows and the software you plan to run on top.

What are the short answers?

Choose PostgreSQL for rich SQL, complex queries, strict data integrity and extensions such as PostGIS, pgvector and TimescaleDB. Choose MySQL, or its community fork MariaDB, when the application is built for it, as many PHP platforms are, or when your team already runs it well. For a new project without constraints, PostgreSQL is the more common recommendation today, but neither is a wrong choice.

AreaMySQL / MariaDBPostgreSQL
SQL featuresSolid core, window functions and CTEs in current versionsVery broad: lateral joins, rich CTEs, partial and expression indexes
Data typesStandard types, JSONArrays, ranges, JSONB with indexing, custom types
ExtensionsStorage engines, pluginsLarge ecosystem: PostGIS, pgvector, TimescaleDB, pg_partman
ReplicationBinary log, GTID, group replication, Galera in MariaDBStreaming physical, logical publication and subscription
Concurrency modelMVCC with undo logs in InnoDBMVCC with row versions and vacuum
Common platformsWordPress, Magento, PrestaShop, DrupalDjango, Rails, analytics and GIS stacks

How do they handle concurrent writes?

Both use multi-version concurrency control, so readers do not block writers. InnoDB keeps old row versions in undo logs and purges them in the background. PostgreSQL writes new row versions into the table and relies on autovacuum to reclaim dead ones. That difference shapes tuning: on PostgreSQL, watch autovacuum on busy tables and avoid long-running transactions that keep dead rows alive; on MySQL, watch the purge lag and history list length.

SELECT relname, n_dead_tup, last_autovacuum FROM pg_stat_user_tables ORDER BY n_dead_tup DESC LIMIT 5;
SHOW ENGINE INNODB STATUS\G

Which replicates more easily?

Both do it well with different strengths. MySQL's binary log replication is simple to set up and widely understood, group replication adds automatic failover, and MariaDB offers Galera for multi-primary clusters. PostgreSQL's streaming replication gives exact physical copies with very low lag, and logical replication copies chosen tables, even between major versions. Tools such as Patroni manage PostgreSQL failover with a consensus store like etcd. Across our servers, replication travels over the public ports, so encrypt it with TLS or a WireGuard tunnel, since we do not sell a private network.

How should memory be set?

Differently. MySQL's InnoDB buffer pool is usually given 60 to 75 percent of memory on a dedicated database host. PostgreSQL's shared_buffers is typically set to about 25 percent, because it also relies on the operating system's page cache; effective_cache_size then tells the planner how much the combination can hold. On a machine with 64 GB:

# MySQL /etc/mysql/mysql.conf.d/tuning.cnf
innodb_buffer_pool_size  = 44G   # roughly 70 percent of 64 GB
innodb_redo_log_capacity = 8G    # MySQL 8.0.30 and later
# PostgreSQL postgresql.conf
shared_buffers       = 16GB
effective_cache_size = 46GB
work_mem             = 48MB

Which is faster?

It depends on the workload far more than the engine. Simple primary key lookups at very high rates have historically favoured MySQL; complex joins, analytical queries and workloads that benefit from advanced index types often favour PostgreSQL. Both are fast enough that schema design, indexes and hardware matter more. Benchmark your own queries on the target machine with pgbench or sysbench before deciding on performance grounds.

How do backups differ?

The tools differ, the principles do not. For MySQL and MariaDB, mysqldump or mydumper produce logical copies, and mariadb-backup or Percona XtraBackup take physical hot backups; binary logs enable point-in-time recovery. For PostgreSQL, pg_dump handles logical copies, while pgBackRest or pg_basebackup with WAL archiving give physical backups and recovery to any moment. In both cases, send copies to a separate server and test restores regularly.

What hardware suits each?

The same things: memory for the working set and fast NVMe for writes. BUSINESS-2 2024 with 64 GB DDR5 and 2x 960 GB SSD NVMe, Soft RAID suits a busy database of either kind for $109.80 a month. Large databases with many concurrent connections fit ENTERPRISE-a2 2026. Our PostgreSQL servers and Database servers pages cover sizing in depth, and Database migration explains moving between the two.

Machines for MySQL and PostgreSQL

ModelProcessorCoresMemoryDrivesPortPer month
ESSENTIAL-SAMD Ryzen 7 9700X864 GB2x 512 GB SSD NVMe1 Gbps unmetered$46.20
BUSINESS-2 2024AMD EPYC 4344P864 GB2x 960 GB SSD NVMe3 Gbps unmetered$109.80
BUSINESS-4 2026AMD EPYC 4585PX1664 GB2x 960 GB SSD NVMe3 Gbps unmetered$212.40
ENTERPRISE-a2 2026AMD EPYC TURIN 925524128 GB2x 1.92 TB SSD NVMe5 Gbps unmetered$446.40

Related pages

PostgreSQL servers

Run PostgreSQL on dedicated hardware: current versions from the project repository, memory settings, NVMe planner costs, replicas, pgBackRest and failover.

Read more

Database servers

NVMe machines with large memory for PostgreSQL, MySQL, MariaDB and MongoDB, from a single primary to replicated pairs.

Read more

Database migration

Moving a database to a new server or engine: dump and restore, replication cutover, schema conversion, validation queries and keeping downtime to minutes.

Read more

WordPress hosting on bare metal

Run WordPress sites on your own dedicated server: nginx and PHP-FPM pools, MariaDB, object and page caching, WP-CLI, cron and many sites per machine.

Read more

Questions and answers

Is PostgreSQL better than MySQL?

Neither is better overall. PostgreSQL offers broader SQL and extensions; MySQL fits many existing PHP platforms and is simple to replicate.

Which database does WordPress use?

MySQL or MariaDB. Most PHP shop and CMS platforms are built for that family.

How much memory should the InnoDB buffer pool get?

Usually 60 to 75 percent of RAM on a dedicated database host.

Why is PostgreSQL shared_buffers only about 25 percent of RAM?

PostgreSQL also uses the operating system page cache, so a moderate shared_buffers plus a large page cache works best.

Can I migrate from MySQL to PostgreSQL?

Yes. Tools such as pgloader convert schema and data; then test queries and application behaviour carefully.