Postgres and wsl2 and podman vs. Postgres and windows

3 points by osigurdson ↗ HN
TLDR: Postgres on Windows is 2.75X faster

Windows

$ ./pgbench -U postgres -c 10 -j 2 -T 60 pgbench

Password:

pgbench (14.2)

starting vacuum...end.

transaction type: <builtin: TPC-B (sort of)>

scaling factor: 10

query mode: simple

number of clients: 10

number of threads: 2

duration: 60 s

number of transactions actually processed: 303691

latency average = 1.966 ms

initial connection time = 302.140 ms

tps = 5087.274385 (without initial connection time)

podman/wsl2

$ ./pgbench -U postgres -c 10 -j 2 -T 60 -p 5433 pgbench

Password:

pgbench (14.2, server 14.10 (Debian 14.10-1.pgdg120+1))

starting vacuum...end.

transaction type: <builtin: TPC-B (sort of)>

scaling factor: 10

query mode: simple

number of clients: 10

number of threads: 2

duration: 60 s

number of transactions actually processed: 110853

latency average = 5.408 ms

initial connection time = 62.968 ms

tps = 1849.121013 (without initial connection time)

8 comments

[ 4.9 ms ] story [ 29.4 ms ] thread
Do you mount a volume in the container to store the data or does PostgreSQL write in the container file system?
I tried two things:

1) podman volume create (and use that volume in the container) 2) do not specify a volume (allowing postgres to write to its own data directory i the container)

The results for both approaches are the same.

I didn't try creating an external bind mount to a Windows directory as I read many articles concluding that this is slow.

Out of curiosity, is Windows your requirement? I wonder how would benchmark on Linux look compared to what you measured on Windows.

Remembering all my experience with WSL I'd guess there are things going on in the background that are hard to debug

In production, postgres is virtually always run on Linux. I suspect pgbench results would be considerably better. This is more of a development use case. Still, the performance degradation even in development is quite impactful.
(comment deleted)
Interestingly, if I install postgres on Ubuntu running under wsl2 (sudo apt install postgres), the performance is twice as good vs running in podman+wsl.

directly in ubuntu on wsl

pgbench -c 10 -j 2 -T 60 pgbench

pgbench (14.10 (Ubuntu 14.10-0ubuntu0.22.04.1)) starting vacuum...end. transaction type: <builtin: TPC-B (sort of)> scaling factor: 10 query mode: simple number of clients: 10 number of threads: 2 duration: 60 s number of transactions actually processed: 197411 latency average = 3.039 ms initial connection time = 8.475 ms tps = 3290.474266 (without initial connection time)

WSL is super nice for dev, but it lacks behind for any sort of performance. Even for ML, it has latencies in moving data to GPUs.
Considering it as a good thing - less chances WSL powered system will be put into production by mistake.