diff --git a/toolset/databases/postgres/config.sh b/toolset/databases/postgres/config.sh index ea3d95e4b7c..8ed1efc94e3 100755 --- a/toolset/databases/postgres/config.sh +++ b/toolset/databases/postgres/config.sh @@ -2,4 +2,11 @@ set -e -cat /tmp/postgresql.conf >> "${PGDATA}/postgresql.conf" +cat /docker-entrypoint-initdb.d/postgresql.conf >> "${PGDATA}/postgresql.conf" + +IO_WORKERS="$(( (`nproc` + 3) / 4 ))" + +# The maximum valid value for the io_workers configuration parameter is 32. +if [[ "$IO_WORKERS" -lt 32 ]]; then + sed -i "s/io_workers = 32/io_workers = ${IO_WORKERS}/" "${PGDATA}/postgresql.conf" +fi diff --git a/toolset/databases/postgres/postgres.dockerfile b/toolset/databases/postgres/postgres.dockerfile index 0573b85b2ca..c5d1db814b3 100644 --- a/toolset/databases/postgres/postgres.dockerfile +++ b/toolset/databases/postgres/postgres.dockerfile @@ -1,10 +1,8 @@ FROM postgres:18-trixie -ENV PGDATA=/ssd/postgresql \ - POSTGRES_DB=hello_world \ +ENV POSTGRES_DB=hello_world \ POSTGRES_PASSWORD=benchmarkdbpass \ POSTGRES_USER=benchmarkdbuser COPY 60-postgresql-shm.conf /etc/sysctl.d/ -COPY config.sh create-postgres.sql /docker-entrypoint-initdb.d/ -COPY postgresql.conf /tmp/ +COPY config.sh create-postgres.sql postgresql.conf /docker-entrypoint-initdb.d/ diff --git a/toolset/databases/postgres/postgresql.conf b/toolset/databases/postgres/postgresql.conf index 72c94956692..5000f5193e5 100644 --- a/toolset/databases/postgres/postgresql.conf +++ b/toolset/databases/postgres/postgresql.conf @@ -5,6 +5,11 @@ listen_addresses = '*' max_connections = 2000 ssl = false +# Tuning AIO in PostgreSQL 18: +# https://vondra.me/posts/tuning-aio-in-postgresql-18 +# The config.sh script sets the actual value based on that article and the runtime environment. +io_workers = 32 + # values from: http://blog.pgaddict.com/posts/performance-since-postgresql-7-4-to-9-4-pgbench # details: http://www.postgresql.org/docs/9.4/static/runtime-config-resource.html # http://www.postgresql.org/docs/9.4/static/runtime-config-wal.html