I've been trying to deploy Postgres within Docker for portability reason, and noticed that query performance as measured by "explain analyze" has been painfully slow compared to bare metal.
For a table with 1.7 million rows, a query on bare metal Postgres takes about 1.2 sec vs 4.8 sec on Dockered Postgres, an increase of 4 times! This comparison is done with the same mounted volume for both bare-metal and Docker (for Docker, I'm using the -v
option) The volume is a gp2 volume, mounted through AWS console, 60GB
Couple of things I tried:
- Increase shared memory buffer option in postgresql.conf, which has negligible effect
- Tried several volume mapping options (delegated, cached, consistent)
- Upgrading Docker from 17.06-ce to 17.12-ce
This is all done in AWS Linux 2 instance. At this point I’m hoping to get more suggestions on what to do to improve performance.
The docker run command I use:
docker run -p 5432:5432 --name postgres -v /vol/pgsql/10.0/data:/var/lib/postgresql/data postgres:latest
docker info
. If Docker is configured to use the devicemapper driver on loopback devices, that might explain some of the performance degradation. – Vineet Reynolds Mar 16 '18 at 3:50docker info
and this is the storage driver I gotStorage Driver: overlay2 Backing Filesystem: xfs Supports d_type: true Native Overlay Diff: true
I'm assuming this is not the devicemapper one? Thanks. – user9500023 Mar 20 '18 at 1:24