Postgres 17.4 vs sysbench on a large server
Postgres has done a great job at avoiding performance regressions over time. It has results from sysbench and a large server for all point releases from Postgres 17.x and then the latest point release from Postgres 10 through 16.
This work was done by Small Datum LLC and not sponsored.
tl;dr - over time ...
- For the 27 microbenchmarks there is one regression that arrives in 11.x and remains through 17.x
- Postgres has many big improvements
- I am still trying to explain the regression but the problem isn't obvious.
- The regression first arrives in Postgres 11.0
- Flamegraphs don't show an obvious problem
- Perf HW counters show an increase in memory system stalls
The tests run with 8 tables and 10M rows/table. There are 40 client threads, read-heavy microbenchmarks run for 180 seconds and write-heavy run for 300 seconds.
(QPS for $version) / (QPS for Postgres 10.23)
Notes on the charts
- the y-axis shows the relative QPS
- the y-axis starts at 0.80 to make it easier to see differences
- in some cases the y-axis truncates the good outliers, cases where the relative QPS is greater than 1.5. I do this to improve readability for values near 1.0. Regardless, the improvements are nice.
- performance is stable over time in most cases
- performance gets much better for hot-points with Postgres 17.0
- performance is stable over time with small improvements for most tests
- performance gets ~1.2X better over time on the scan test
- these do a short range scan with aggregation and the =10, =100 and =10000 is the number of rows scanned per query
- performance is stable over time on the tests that do shorter range scans (=100, =10)
- performance drops by ~10% starting in 11.22 on the test with a longer range scan (=10000)
- depending on the test, performance over time is either stable, has a small improvement or has a large improvement
For the read-only_range=10000 tests where QPS drops by ~10% starting in 11.22 the problem is that Postgres uses more CPU per query starting in 11.22 (see the cpu/o column which stands for CPU per operation or CPU per query).
Metrics per test from vmstat and iostat are here and I highlighted results for the read-only_range=X tests that do a range scan with aggregation.
Things I have checked for read-only_range=10000
- output from ps for 10.23, 11.22 and 12.22 looks similar
- output from vmstat for 10.23, 11.22 and 12.22 looks similar with a few small differences. This output is from the middle of the microbenchmark.
- both swpd and free are larger in 11.22 and 12.22
- both buff and cache are larger in 10.23
- for 10.23, 11.22 and 12.22 those values don't change during the microbenchmark
- Flamegraphs for 10.23, 11.22 and 12.22 are here and look similar. The numbered (*.1.svg, *.2.svg) files are taken in sequence and then all are combined to create the *.all.svg file.
- Output with perf HW counters for 10.23, 11.0 and 11.10 are here. These show there are more memory system stalls starting in 11.0. I haven't explained the file naming scheme, but the data in the table below is from this file.
- Flat (no flamegraphs) perf profiles are here for 10.23, 11.0 and 11.10. There are ~8 samples per DBMS version and the 7th sample is here for 10.23, for 11.0 and for 11.10. From a quick check of them I don't see obvious problems.