Compare

PostgreSQL vs MySQL: I Benchmarked Both on 1 Million Rows

November 23, 2026
PostgreSQL
Open Source
VS
MySQL
Open Source

Pick PostgreSQL if

You are starting a new app and want the faster, lighter default for both everyday writes and reports.

Pick MySQL if

Your software is built for it, like WordPress, or your host only offers MySQL.

PostgreSQL vs MySQL: I Benchmarked Both on 1 Million Rows

I loaded the same 1 million transactions into both, on default settings and identical limits. PostgreSQL won every timed test: 1.4 to 2.9 times faster on writes, 1.2 to 6.2 times faster on reads and reports, and it idled at about a tenth of MySQL's memory. MySQL stored the same table in less space. The raw results and the test script are linked under "How I tested".

Bar chart of my benchmark, PostgreSQL 19 against MySQL 26.10 on 1 million rows with default settings. PostgreSQL was faster in all ten tests: loading the CSV 2.7x, total per category 4.8x, count per month 2.1x, join with group by 5.5x, top 10 customers 1.2x, filtering one customer without an index 6.2x, 1,000 single-row saves 2.9x, 1,000 updates 2.9x, 10,000 rows in one transaction 1.5x, and 8 clients writing at once 1.4x.
Same data, same limits, default settings: PostgreSQL ahead in every timed test.

That is a more one-sided result than I expected from two databases as mature as PostgreSQL and MySQL, so most of this page is about how I made it fair, and where it stops applying.

PostgreSQL vs MySQL at a glance

PostgreSQL 19MySQL 26.10
LicencePostgreSQL License, similar to BSD or MITGPL v2 for the Community edition; commercial licence from Oracle if you ship it inside closed-source software
Saves to disk on every commit by defaultYesYes
Docker image size (unpacked)170 MB299 MB
Memory after starting, idleAbout 40 MBAbout 432 MB
My 1 million row table on disk89.7 MB57.2 MB
Best forNew apps, mixed reads and writes, reporting on the same databaseWordPress and other software built for MySQL, hosts that only offer MySQL

Which is faster for everyday app writes?

PostgreSQL, by about three times for single-row work. These are the medians on default settings:

TaskPostgreSQLMySQLFaster
1,000 inserts, each saved on its own1.03 s2.94 sPostgreSQL, 2.9x
1,000 updates by id, each saved on its own0.98 s2.88 sPostgreSQL, 2.9x
10,000 inserts in one transaction1.60 s2.33 sPostgreSQL, 1.5x
8 clients inserting 4,000 rows at the same time2.09 s2.97 sPostgreSQL, 1.4x
Fetch one row by id0.2 ms0.4 msBoth instant

The single-row saves matter most here, because that is what a web app does all day: save an order, update a profile, mark a message read. Both databases wait for the disk to confirm each commit by default (PostgreSQL's synchronous_commit is on, and MySQL's manual says its default "is required for full ACID compliance"), so this is like for like. PostgreSQL simply finished each commit faster on the same disk.

The gap narrowed when the work was batched into one transaction, or spread over 8 clients at once. In those tests PostgreSQL was still ahead, by about 1.4 to 1.5 times.

Which is faster for reports and searches?

PostgreSQL again, and by more on queries that read the whole table:

Query on 1 million rowsPostgreSQLMySQLFaster
Join 100,000 customers, total by country and segment0.41 s2.24 sPostgreSQL, 5.5x
Total spend per category0.14 s0.66 sPostgreSQL, 4.8x
Count of transactions per month0.19 s0.41 sPostgreSQL, 2.1x
Top 10 customers by spend0.66 s0.78 sPostgreSQL, 1.2x
One customer's transactions, no index26 ms161 msPostgreSQL, 6.2x
The same, after adding an index0.2 ms0.3 msBoth instant
Load the 1 million row CSV1.85 s5.03 sPostgreSQL, 2.7x

Both returned exactly the same rows for every query, which I checked after every run. Here is the join typed into each database's own command-line client, with its timer on:

Terminal running psql 19.0: it creates the two tables, loads 1 million and 100,000 rows with COPY, runs a join that totals spend by country and segment, and shows the top 5 rows. The timer reports 402.947 milliseconds.
PostgreSQL's psql: the join in 0.40 seconds.
Terminal running the mysql client 26.10.0: after ANALYZE TABLE, the same join returns the same top 5 country and segment totals in 2.186 seconds.
MySQL's client: the same 5 rows in 2.19 seconds.

The last row of the table is the one to remember. Without an index, finding one customer's transactions means reading the whole table, and MySQL took six times longer to do it. With an index on the customer column, both answered in a fraction of a millisecond. On either database, the index matters far more than the engine.

Does MySQL catch up if you give it more memory?

Not on this data. MySQL keeps table data in a memory area called the buffer pool, 128 MB by default, and its manual says that on dedicated servers "up to 80% of physical memory is often assigned" to it. PostgreSQL's own guidance suggests 25% of memory for shared_buffers as a starting point.

So I ran everything again with MySQL's buffer pool at 2 GB and PostgreSQL's shared_buffers at 1 GB, half and a quarter of the 4 GB limit. Memory use went up for both, and speed did not improve for either. In that one tuned run, MySQL won two tests: the lookup by id, where both stayed under half a millisecond, and the top 10 customers query, 0.82 s against PostgreSQL's 1.14 s. PostgreSQL had done that query in 0.66 s on default settings, so with a single tuned run I would treat that as noise rather than a real win. Every other test kept PostgreSQL ahead.

The reason is size: my whole MySQL table is 57 MB, so it already fit inside the default 128 MB buffer pool. If your tables are many times bigger than that, the default really is too small, and raising it is the first change to make.

Where MySQL still makes sense

  • Software that expects it. WordPress's requirements list MySQL 8.4 or MariaDB 10.11 or newer as the database, and nothing else. If your app or host is built around MySQL, a faster database it cannot use does not help you.
  • Smaller tables on disk. The same 1 million rows took 57.2 MB in MySQL and 89.7 MB in PostgreSQL. That is about a third less disk space for the same data.
  • A team that already runs it well. A database your team knows how to back up, tune and restore beats a faster one it does not.

How I tested

  • Machine: a laptop running each database alone in Docker, limited to 2 CPUs and 4 GB of memory, with its data in a Docker volume. The test client ran in a separate container on the same Docker network.
  • Versions: the newest official images at the time of testing, PostgreSQL 19.0 and MySQL 26.10.0, on their default settings unless stated.
  • Data: the same 1,000,000 generated transactions and 100,000 customers as my SQLite vs DuckDB test, built from a fixed random seed.
  • Loading: each database's own bulk path, COPY for PostgreSQL and LOAD DATA for MySQL.
  • Runs: each query 10 times after a warm-up, each write test 3 times, and every test round repeated. PostgreSQL ran twice. MySQL ran four times: twice with the PyMySQL driver and twice with Oracle's own mysql-connector-python driver and its compiled C extension. The numbers on this page are medians, with MySQL's from the official driver. The driver made almost no difference, within about 10% on every test.
  • Run to run: PostgreSQL's two rounds stayed within a few percent of each other. One of MySQL's four rounds was slower across the board (the join took 3.5 s instead of 2.1 to 2.3 s). It is in the raw data, and the medians keep it from moving the results.
  • What this test doesn't cover: tables bigger than memory, hundreds of connections, replication, other operating systems or disks, and tuning beyond the one memory setting above. It is a fair look at the defaults most people start with, not a ranking for every workload.
  • A mistake I fixed: my first MySQL load split the CSV on the wrong line ending and kept a hidden character at the end of each row. The totals still matched, but one query's groups did not, so I fixed the load and ran everything again. Every result on this page comes after that fix.

The raw numbers for every run are in my results CSV, and the test script is here as plain text. Everything needed to rerun it (Docker setup, scripts and the raw results of every run) is in my benchmark repo on GitHub.

Which should you choose?

  • A new web app or API with ordinary reads and writes: PostgreSQL.
  • Reports and searches on the same database as the app: PostgreSQL, and add indexes for the filters you use most.
  • WordPress, or a PHP app built for MySQL: MySQL (or MariaDB), and raise the buffer pool once your data outgrows 128 MB.
  • Tight on disk space for a large, simple table: MySQL stored my table in about a third less space.
  • You already run one of them well: keep it. The gaps here are real, but smaller than the cost of a migration done badly.

Changes to this page

  • Bench v1: first results, PostgreSQL 19.0 and MySQL 26.10.0 on 1 million rows, default and tuned memory settings, two MySQL drivers.

How we compare: prices, plans and features come from each product’s official site, pricing page or app store listing. See how we write.

Muhammad Mairaj
Muhammad Mairaj
Muhammad Mairaj is a Senior Backend Engineer with 8 years building payment and data systems. He tests software the way an engineer evaluates it. He is a Partner at Softstribe Solutions and a Senior Software Engineer (Backend) at Funavry Technologies in Islamabad, and he worked on payments at NayaPay.
More from Muhammad Mairaj