


Abstract
The reference system is an IBM POWER9 LC921 running Debian 13 ppc64le, with 32 cores, 128 hardware threads and 128 GB of RAM across two NUMA nodes. Several things differ from a typical x86_64 server: a 64 KB base page size, NUMA node IDs of 0 and 8, SMT4 threading, and a HugePage size that depends on the MMU mode. Those details are covered here alongside the usual storage, kernel and PostgreSQL setup.
This guide takes a fresh Debian 13 install to a tuned PostgreSQL 18 server. The focus is installation and configuration. A benchmarking section near the end then shows what the finished system does and tests PostgreSQL 18’s worker and io_uring I/O methods.
What you will build
- A two-disk SAS SSD software RAID 1 array (
mdadm+ XFS) dedicated to the database. - A PostgreSQL 18 cluster from the official PGDG repository, created on that array with Debian’s
pg_createclusterwrapper. - NUMA-interleaved shared memory, static HugePages, and Transparent Huge Pages (THP) disabled.
- Memory and parallel-query settings sized for 128 GB of RAM and 32 cores / 128 hardware threads.
Out of scope: backups and high availability, TLS, monitoring, query-level tuning, and RAID or disk-failure handling beyond initial array creation.
Reader Note on Example Values: The hostname (
hydra), user account (beaker), block devices (/dev/sda,/dev/sdb,/dev/sdc,/dev/md127,/dev/md127p1; thesdXletters change between boots), IP subnet (192.168.6.0/26), mount point (/hydra-ssd) and UUIDs shown throughout are the values from the reference system. Substitute the devices, paths and identifiers of your own deployment. Commands are shown with the prompt of the shell running them (beaker@hydra:~$at the shell,postgres=#insidepsql), so it is clear which user is acting and when elevated privileges are used. Do not paste the prompt itself. Example output is shown in separate blocks.
Prerequisites
- Debian 13 (Trixie) installed on the OS drive and fully updated (
sudo apt update && sudo apt full-upgrade). - A user with
sudoaccess and working network connectivity toapt.postgresql.org. - Two spare disks for the database array. The commands below destroy any data on them.
- Abstract
- Reference System
- Storage Configuration & RAID 1 Setup
- Host Kernel, NUMA & HugePages Pre-Configuration
- Repository Configuration & PostgreSQL Installation
- Cluster Creation on the SSD Array
- Systemd Integration: NUMA Interleaving & Mount Dependencies
- Network & Authentication Configuration
- PostgreSQL Performance Tuning
- First Start & Verification
- Provisioning the NetBox Role and Database (Optional)
- Benchmarking (Optional)
- Helpful Links
Reference System
Hardware
| Component | Specification / Model | Notes |
|---|---|---|
| Host System / Chassis | IBM 9006-12P LC921 (OpenPOWER) | 1U rackmount dual-socket server (hydra) |
| CPU | 2 × IBM POWER9 (16 cores, 64 threads each @ 2.2 GHz base) | 32 physical cores / 128 hardware threads (SMT4) |
| Memory | 128 GB DDR4 ECC Registered | Dual-node NUMA topology (2 nodes × 64 GB) |
| OS Drive | Supermicro SuperDOM 64GB SATA3 (SSD-DM064-PHI) | Dedicated root OS drive |
| Database Storage | 2 × 960 GB Enterprise SAS 12Gb/s SSDs | Samsung EMC960 (P1633N09), SPL-4 |
| Storage Architecture | Linux Software RAID 1 (mdadm), GPT partition, XFS | Array hydra:hydra-ssd (/dev/md127, partition /dev/md127p1), mounted at /hydra-ssd |
| Network (onboard) | Intel X710/X557-AT quad-port 10GBASE-T (integrated) | Not used in this guide |
| Network (add-in) | Mellanox ConnectX-4 (MT27700 family) PCIe NIC, 40 Gb/s link | mlx5_core driver. Not used in this guide’s tuning; no network tuning is covered |
Software
| Software Layer | Version / Build | Source / Notes |
|---|---|---|
| Operating System | Debian GNU/Linux 13 (Trixie), ppc64le | 64-bit PowerPC Little Endian, 64 KB base page. Debian’s own architecture name is ppc64el (dpkg --print-architecture); ppc64le is the common/GNU name for the same thing. |
| Linux Kernel | 6.12.111+deb13-powerpc64le | Standard Debian kernel with io_uring support |
| Database Engine | PostgreSQL 18.6 (Debian 18.6-1.pgdg13+2) | PGDG build, official apt.postgresql.org release |
| System Utilities | numactl, powerpc-utils, xfsprogs, mdadm, parted | Standard Debian package repository |
Storage Configuration & RAID 1 Setup
The database gets its own array for two practical reasons: capacity that does not compete with the OS drive (a 64 GB SuperDOM fills quickly), and mount-level filesystem and queue settings that you would not want to apply to the root volume.
1. Install Storage & Architecture Utilities
These packages provide the RAID tooling, the XFS utilities, partitioning, and the NUMA and POWER-specific tools used later.
beaker@hydra:~$ sudo apt update && sudo apt install -y mdadm xfsprogs parted numactl powerpc-utils
2. Assemble the Software RAID 1 Array
First identify the two raw SAS disks. Drive letters can change between boots (see the note below the command), so record each disk’s WWN, a permanent identifier, along with its current name:
beaker@hydra:~$ lsblk -d -o NAME,SIZE,MODEL,WWN
Example output:
NAME SIZE MODEL WWN
sda 895G P1633N09 EMC960 0x5002538a06c70f20
sdb 59.6G SATA SSD
sdc 895G P1633N09 EMC960 0x5002538a06c6f540
The two 895 GB Samsung SSDs are the database disks. The 59.6 GB OS drive shows an empty WWN, which does not matter because it is not part of the array.
The command below creates the mirror with an explicit array name and a write-intent bitmap. The bitmap (--bitmap=internal) keeps a dirty-block record in the array metadata, so after a power loss or kernel panic only the dirty regions are resynchronized instead of the whole array. Replace the two placeholders with the WWN values for your disks (each value includes its 0x prefix). On the reference system the two paths are /dev/disk/by-id/wwn-0x5002538a06c70f20 and /dev/disk/by-id/wwn-0x5002538a06c6f540:
beaker@hydra:~$ sudo mdadm --create --verbose /dev/md/hydra-ssd \
--name=hydra-ssd \
--level=1 \
--raid-devices=2 \
--bitmap=internal \
/dev/disk/by-id/wwn-<WWN of first disk> \
/dev/disk/by-id/wwn-<WWN of second disk>
Drive letters are not stable: Names such as
/dev/sdaand/dev/sdbare assigned in the order the kernel detects the disks, and on SAS systems that order can change between boots. On the reference system the letters changed more than once, so the letters shown in this guide will not necessarily match what you see. The array itself is not affected, becausemdadmidentifies its members by the metadata on the disks, not by letter. Your own commands are affected: a wrong letter inmdadm --createor a check can hit the wrong disk, including the OS drive. That is why the create command uses the persistent names under/dev/disk/by-id/, which belong to the drive itself and stay correct when the letters move. Use plainsdXletters only for read-only checks, and confirm them withlsblkfirst.
The array starts an initial sync in the background and is usable immediately; watch progress with cat /proc/mdstat. To make the array assemble predictably at boot, record its definition in mdadm.conf and rebuild the initramfs:
beaker@hydra:~$ sudo mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.conf > /dev/null
beaker@hydra:~$ sudo update-initramfs -u
Check array health and bitmap status (/dev/md/hydra-ssd is a symlink to /dev/md127 on the reference system):
beaker@hydra:~$ sudo mdadm --detail /dev/md/hydra-ssd
Example output:
/dev/md/hydra-ssd:
Version : 1.2
Creation Time : Sun Aug 30 18:31:50 2026
Raid Level : raid1
Array Size : 938343424 (894.87 GiB 960.86 GB)
Used Dev Size : 938343424 (894.87 GiB 960.86 GB)
Raid Devices : 2
Total Devices : 2
Persistence : Superblock is persistent
Intent Bitmap : Internal
Update Time : Mon Oct 19 00:49:14 2026
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
Consistency Policy : bitmap
Name : hydra:hydra-ssd (local to host hydra)
UUID : c0da3a85:69c3c462:1bff5a5f:d4fe318d
Events : 37
Number Major Minor RaidDevice State
0 8 0 0 active sync /dev/sda
1 8 16 1 active sync /dev/sdb
3. Partition the Array
A RAID 1 array can be formatted directly without partitioning. This guide uses a single GPT partition to match the reference system. The command creates the label and one partition spanning the array, and lsblk then shows the new partition nested under both member disks.
beaker@hydra:~$ sudo parted -s -a optimal /dev/md/hydra-ssd mklabel gpt mkpart primary xfs 0% 100%
beaker@hydra:~$ lsblk -o NAME,SIZE,MODEL
Confirm the partition device name from lsblk (it is /dev/md127p1 on the reference system) and use that name in the next step.
4. Format and Mount the XFS Filesystem
XFS suits a database volume because it handles large files and parallel writers well. The -s size=4096 option sets a 4 KB sector size to match the SSDs’ native block size, and the label makes the volume easy to recognize in lsblk and blkid output.
beaker@hydra:~$ sudo mkfs.xfs -f -s size=4096 -L hydra_ssd /dev/md127p1
beaker@hydra:~$ sudo mkdir -p /hydra-ssd
beaker@hydra:~$ sudo blkid /dev/md127p1
blkid prints the filesystem UUID, which is not the same as the mdadm array UUID. Use the filesystem UUID in /etc/fstab, because device names such as /dev/md127 can change between boots.
Example output:
/dev/md127p1: UUID="b536d0b7-9f92-4f5e-b689-3f790481e63a" BLOCK_SIZE="4096" TYPE="xfs" PARTUUID="83ee377a-3ec2-484f-82f7-650245caec33"
Add the line below to /etc/fstab, replacing the UUID with your own blkid output. The option choices are:
noatimestops inode access-time updates on every read or index scan, which removes needless metadata writes.logbsize=256kraises the XFS journal buffer size to the maximum (the default is much smaller), which can reduce journal write overhead on metadata-heavy workloads. This applies to the XFS metadata journal, not PostgreSQL’s WAL.- The final
0 0means nodumpand no boot-timefsck; XFS does not usefsckat boot. - No
discardoption. Continuous inline discard can cause latency spikes. Trim periodically instead with Debian’s timer (sudo systemctl enable --now fstrim.timer). - No
allocsizeoption either. Setting a fixedallocsizeturns off XFS’s dynamic end-of-file preallocation, which adapts to each file’s growth pattern. PostgreSQL also allocates WAL segments at their full size itself, so there is little for a fixed value to gain.
# /etc/fstab: Dedicated PostgreSQL RAID 1 volume
UUID=b536d0b7-9f92-4f5e-b689-3f790481e63a /hydra-ssd xfs defaults,noatime,logbsize=256k 0 0
Note: These option values are sensible starting points for a database volume. They were not individually benchmarked for this guide.
Now reload systemd’s view of /etc/fstab, mount the volume, and inspect the filesystem geometry to confirm the 4 KB sector size (sectsz=4096):
beaker@hydra:~$ sudo systemctl daemon-reload
beaker@hydra:~$ sudo mount -a
beaker@hydra:~$ sudo xfs_info /hydra-ssd
5. I/O Scheduler & Queue Tuning for Enterprise SAS SSDs
Two layers matter here. The physical member SSDs have the real request queues, so the scheduler and queue depth are set there. SCSI/SATA SSDs default to mq-deadline; for fast SSDs behind a database, none removes the elevator layer and its locking overhead. Readahead is different: the filesystem reads through the RAID device, so read_ahead_kb belongs on the md device, not on the members. A value of 64 KB (the default is typically 128 KB) reduces page-cache pollution from random 8 KB PostgreSQL page reads.
Persist the settings with a udev rule. Device letters can change between boots on SAS systems, and a swap would apply the rule to the OS drive, so match on a stable attribute instead of the letter. List the candidates first:
beaker@hydra:~$ udevadm info -a -n /dev/disk/by-id/wwn-<WWN of first disk> | grep -E 'ATTRS\{(vendor|model|wwid|serial)\}'
On the reference system the model attribute is P1633N09 EMC960 (the SCSI model field is padded with a trailing space, so the rule matches on the prefix). The file is numbered 65 on purpose: the RAID rule depends on MD_NAME, which mdadm’s own rules (63-md-raid-arrays.rules) set, so this file must sort after them or that rule silently never matches. Adjust the match for your drives:
beaker@hydra:~$ sudo tee /etc/udev/rules.d/65-ssd-scheduler.rules << 'EOF'
# Member SSDs: no elevator, deeper request queue
ACTION=="add|change", SUBSYSTEM=="block", KERNEL=="sd*[!0-9]", ATTRS{model}=="P1633N09*", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="none", ATTR{queue/nr_requests}="256"
# RAID device: lower readahead for random 8 KB reads
ACTION=="add|change", SUBSYSTEM=="block", KERNEL=="md*", ENV{MD_NAME}=="hydra:hydra-ssd", ATTR{queue/read_ahead_kb}="64"
EOF
Check this against your hardware: The
ATTRS{model}match is specific to the reference system’s drives. If it does not match yours, the rule silently does nothing, and if it is too broad it can also change the OS drive. After applying the rule (below), confirm that the scheduler shows[none]on the database disks only.
nr_requests is bounded by the hardware queue depth, so the effective value may be lower than 256. Apply the rules without rebooting and verify. For readahead, check the partition the filesystem actually sits on:
beaker@hydra:~$ sudo udevadm trigger --subsystem-match=block --action=change
beaker@hydra:~$ grep . /sys/block/sd*/queue/{scheduler,nr_requests}
beaker@hydra:~$ sudo blockdev --getra /dev/md127p1
Example output (blockdev reports 512-byte sectors, so 64 KB reads as 128):
/sys/block/sda/queue/scheduler:[none] mq-deadline
/sys/block/sdb/queue/scheduler:none [mq-deadline]
/sys/block/sdc/queue/scheduler:[none] mq-deadline
/sys/block/sda/queue/nr_requests:256
/sys/block/sdb/queue/nr_requests:256
/sys/block/sdc/queue/nr_requests:256
128
In this output sdb is the OS drive, which correctly keeps its default scheduler, and sda and sdc are the two database SSDs.
Scheduler Note: NVMe devices default to
none; SCSI/SATA SSDs (/dev/sd*) default tomq-deadline. Other schedulers (bfq,kyber) are optional modules on Debian and are not needed for low-latency database arrays. As with the mount options, these values are reasonable starting points rather than separately benchmarked results.
Host Kernel, NUMA & HugePages Pre-Configuration
On a dual-socket POWER9 LC921, the 128 GB of RAM is split into two 64 GB NUMA nodes joined by the SMP interconnect (X-bus). Debian on ppc64le uses a 64 KB base page size, and dedicating HugePages to PostgreSQL reduces Translation Lookaside Buffer (TLB) pressure across a 32 GB shared buffer pool.
1. Inspect NUMA & HugePage Sizes
Start by looking at the topology and the default HugePage size, since the HugePage arithmetic in the next step depends on it.
beaker@hydra:~$ numactl --hardware
beaker@hydra:~$ grep Hugepagesize /proc/meminfo
Example output:
Hugepagesize: 2048 kB
The default HugePage size depends on the MMU mode. POWER9 uses the radix MMU by default, which gives 2 MB huge pages. The older hash MMU (selectable with the disable_radix kernel option) uses 16 MB. The reference system runs radix, so this guide uses 2 MB pages; if yours reports 16 MB, use the second formula below.
On POWER9 the NUMA node IDs are 0 and 8, not 0 and 1 (they follow IBM’s chip ID numbering). Keep this in mind when reading
numactlandnumastatoutput.
2. Calculate Static HugePages
For a planned shared_buffers = 32GB, reserve enough static HugePages for the buffer pool plus a margin of roughly 5% for lock tables and other shared structures:
- 2048 kB (2 MB) pages:
(32 × 1024 MB) / 2 MB = 16,384 pages, so setvm.nr_hugepages = 17200 - 16384 kB (16 MB) pages:
(32 × 1024 MB) / 16 MB = 2,048 pages, so setvm.nr_hugepages = 2150
Before the first start, you can replace this estimate with an exact number (see Check the Exact HugePage Requirement below).
3. Configure Kernel Sysctl Parameters
Four settings go into one drop-in file. Automatic NUMA balancing is disabled because its page-fault sampling can disturb a large shared buffer pool. zone_reclaim_mode = 0 allows allocation to spill to the other node instead of reclaiming local memory aggressively. The static HugePage pool is reserved up front, and vm.swappiness = 1 strongly prefers keeping database memory out of swap.
beaker@hydra:~$ sudo tee /etc/sysctl.d/99-postgresql-tuning.conf << 'EOF'
# --- NUMA Tuning ---
kernel.numa_balancing = 0
vm.zone_reclaim_mode = 0
# --- HugePages & Virtual Memory ---
# Pre-allocate static HugePages (17200 * 2MB = ~33.6 GB)
vm.nr_hugepages = 17200
vm.swappiness = 1
EOF
Apply the settings and verify that the HugePages were reserved:
beaker@hydra:~$ sudo sysctl --system
beaker@hydra:~$ grep -i hugepage /proc/meminfo
Example output:
AnonHugePages: 12288 kB
ShmemHugePages: 0 kB
FileHugePages: 0 kB
HugePages_Total: 17200
HugePages_Free: 17200
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
4. Disable Transparent Huge Pages (THP)
Transparent Huge Pages can cause unpredictable allocation stalls and compaction latency with database workloads, and PostgreSQL uses the static HugePages above instead. Check the current state first:
beaker@hydra:~$ cat /sys/kernel/mm/transparent_hugepage/enabled
Example output:
[always] madvise never
The cleanest way to make the change persistent is a tmpfiles.d rule. systemd-tmpfiles applies it early in boot, long before any PostgreSQL unit starts, so no explicit service ordering is needed:
beaker@hydra:~$ sudo tee /etc/tmpfiles.d/disable-thp.conf << 'EOF'
w /sys/kernel/mm/transparent_hugepage/enabled - - - - never
w /sys/kernel/mm/transparent_hugepage/defrag - - - - never
EOF
beaker@hydra:~$ sudo systemd-tmpfiles --create /etc/tmpfiles.d/disable-thp.conf
beaker@hydra:~$ cat /sys/kernel/mm/transparent_hugepage/enabled
Expected output:
always madvise [never]
An alternative is to add
transparent_hugepage=neverto the kernel command line in your bootloader configuration.
Repository Configuration & PostgreSQL Installation
Debian 13 ships PostgreSQL 17 in its default archives. To install PostgreSQL 18 on ppc64le, configure the official PostgreSQL Global Development Group (PGDG) repository.
1. Add the PGDG APT Repository
The postgresql-common package provides an automated repository setup script.
beaker@hydra:~$ sudo apt install -y curl ca-certificates gnupg postgresql-common
beaker@hydra:~$ sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y
2. Stop Debian from Creating a Default Cluster
Debian’s packaging creates and starts a default cluster at /var/lib/postgresql/18/main when the server package is installed. We want the cluster on the SSD array from the start, so tell the packaging not to create one. The setting must be in place before the PostgreSQL packages are installed:
beaker@hydra:~$ sudo sed -i 's/^#\?create_main_cluster.*/create_main_cluster = false/' /etc/postgresql-common/createcluster.conf
beaker@hydra:~$ grep create_main_cluster /etc/postgresql-common/createcluster.conf
3. Install PostgreSQL 18 Packages
With no default cluster to create, the install completes without starting anything.
beaker@hydra:~$ sudo apt install -y postgresql-18 postgresql-client-18
beaker@hydra:~$ pg_lsclusters
pg_lsclusters should print no clusters yet.
Cluster Creation on the SSD Array
1. Prepare the Directory
PostgreSQL refuses to start if the data directory is readable by other users, so create the parent with strict ownership and permissions. The mount point itself must also be traversable by the postgres user.
beaker@hydra:~$ sudo mkdir -p /hydra-ssd/pgsql
beaker@hydra:~$ sudo chown postgres:postgres /hydra-ssd/pgsql
beaker@hydra:~$ sudo chmod 0700 /hydra-ssd/pgsql
beaker@hydra:~$ sudo chmod 0755 /hydra-ssd
2. Create the Cluster
First confirm that the locale used below exists (if it is missing, run sudo dpkg-reconfigure locales and enable it):
beaker@hydra:~$ locale -a | grep -i 'en_US.utf'
Debian’s pg_createcluster wrapper registers the cluster with the packaging tools (unit files, pg_lsclusters, upgrade tooling) and places the configuration in /etc/postgresql/18/main/, which a raw initdb would not. Keep Debian’s version/cluster directory convention (/hydra-ssd/pgsql/18/main) so side-by-side clusters and major-version upgrades stay simple. There is no --start here: the cluster is configured first and started once.
beaker@hydra:~$ sudo pg_createcluster 18 main \
--datadir=/hydra-ssd/pgsql/18/main \
--locale=en_US.UTF-8
beaker@hydra:~$ pg_lsclusters
Example output (abridged):
Creating new PostgreSQL cluster 18/main ...
/usr/lib/postgresql/18/bin/initdb -D /hydra-ssd/pgsql/18/main --auth-local peer --auth-host scram-sha-256 --no-instructions --locale en_US.UTF-8
The files belonging to this database system will be owned by user "postgres".
...
Data page checksums are enabled.
...
Ver Cluster Port Status Owner Data directory Log file
18 main 5432 down postgres /hydra-ssd/pgsql/18/main /var/log/postgresql/postgresql-18-main.log
PostgreSQL 18 Checksum Behavior: Starting in PostgreSQL 18,
initdbenables data page checksums by default. If you need them off, pass-- --no-data-checksumsat the end of thepg_createclustercommand.
Systemd Integration: NUMA Interleaving & Mount Dependencies
Debian runs each cluster as an instantiated service (postgresql@<version>-<cluster>). Rather than editing the packaged unit, which upgrades overwrite, write a drop-in override for instance 18-main. It does three things:
RequiresMountsFor=/hydra-ssdmakes systemd mount the filesystem before starting the database, so a late or failed mount cannot cause PostgreSQL to start against an empty directory.NUMAPolicy=interleavewithNUMAMask=alloverrides Linux’s default first-touch policy, so shared memory is spread across both sockets instead of landing on whichever node touches it first.LimitMEMLOCK=infinityremoves the locked-memory limit. With static HugePages it may not be needed on Debian 13’s kernel, but it is harmless and avoids memlock-related surprises, particularly withio_uring.
beaker@hydra:~$ sudo mkdir -p /etc/systemd/system/postgresql@18-main.service.d
beaker@hydra:~$ sudo tee /etc/systemd/system/postgresql@18-main.service.d/override.conf << 'EOF'
[Unit]
RequiresMountsFor=/hydra-ssd
[Service]
# Interleave memory across all NUMA nodes (nodes 0 and 8 on this platform)
NUMAPolicy=interleave
NUMAMask=all
LimitMEMLOCK=infinity
EOF
beaker@hydra:~$ sudo systemctl daemon-reload
Network & Authentication Configuration
Configuration files stay in Debian’s standard location, /etc/postgresql/18/main/. This guide sets the listening address directly in postgresql.conf. Every other customization goes in conf.d/ drop-in files (Debian’s postgresql.conf includes this directory), which keeps those changes easy to review and easy to revert.
1. Network Listening Interface
By default PostgreSQL listens only on localhost. Listening on all interfaces is acceptable here because pg_hba.conf (next step) restricts which clients may connect; on a multi-homed host you can list specific addresses instead. The stock postgresql.conf ships with this setting commented out, so the command below uncomments it and changes the value in place. This setting takes effect at the first start.
beaker@hydra:~$ sudo -u postgres sed -i "s/^#\?listen_addresses = .*/listen_addresses = '*'/" /etc/postgresql/18/main/postgresql.conf
Confirm that exactly one active line remains:
beaker@hydra:~$ grep -n '^listen_addresses' /etc/postgresql/18/main/postgresql.conf
2. Client Authentication (pg_hba.conf)
Debian’s default pg_hba.conf already allows local socket connections with peer authentication and loopback TCP connections with scram-sha-256. The only addition needed is a line for your trusted subnet (the example subnet below is from the reference system; replace it with your network). Appending with tee -a avoids opening an editor:
beaker@hydra:~$ echo 'host all all 192.168.6.0/26 scram-sha-256' | sudo -u postgres tee -a /etc/postgresql/18/main/pg_hba.conf
Afterwards the file should contain, among its stock lines:
# TYPE DATABASE USER ADDRESS METHOD
local all all peer
host all all 127.0.0.1/32 scram-sha-256
host all all ::1/128 scram-sha-256
host all all 192.168.6.0/26 scram-sha-256
PostgreSQL Performance Tuning
With 128 GB of RAM, 32 physical POWER9 cores (128 hardware threads) and enterprise SAS SSDs, the settings below are starting points. They are not a universal recommendation, so workload-specific tuning is still needed.
1. Core Memory & WAL Parameters
The memory settings follow common sizing rules for a dedicated 128 GB host: about 25% of RAM for shared_buffers, and an effective_cache_size that tells the planner roughly how much the buffer pool plus OS cache can hold. huge_pages = on makes PostgreSQL fail at startup if the static HugePages are unavailable, instead of silently falling back to small pages. The WAL sizes reduce checkpoint frequency under write bursts, and random_page_cost = 1.1 reflects cheap random reads on SSD.
effective_io_concurrency is deliberately left at its PostgreSQL 18 default (16). Older guides often suggest 200 for SSDs, but that advice predates AIO, and the value now influences how far ahead asynchronous reads are issued. It is tested in the Benchmarking section rather than assumed.
beaker@hydra:~$ sudo -u postgres tee /etc/postgresql/18/main/conf.d/90-memory-wal.conf > /dev/null << 'EOF'
# Memory (128 GB host across 2 NUMA nodes)
shared_buffers = 32GB # ~25% of RAM, interleaved across nodes (default: 128MB)
effective_cache_size = 96GB # ~75% of RAM; buffer pool + OS cache (default: 4GB)
work_mem = 64MB # per sort/hash operation; conservative baseline (default: 4MB)
maintenance_work_mem = 2GB # VACUUM, CREATE INDEX, ALTER TABLE (default: 64MB)
# HugePages
huge_pages = on # fail at startup if static HugePages are unavailable (default: try)
# Checkpoints & WAL
max_wal_size = 8GB # fewer checkpoints under write bursts (default: 1GB)
min_wal_size = 1GB # baseline WAL segment retention (default: 80MB)
# SSD storage
random_page_cost = 1.1 # random reads are cheap on SSD (default: 4.0)
EOF
2. POWER9 SMT Modes & Parallel Query Tuning
POWER9 can change its simultaneous multithreading (SMT) mode at runtime with ppc64_cpu (from the powerpc-utils package, in /usr/sbin; requires root). The setting does not persist across reboots.
- SMT1 (
sudo ppc64_cpu --smt=1): 32 hardware threads, one per core. Gives each thread the most core resources; typically favors single-threaded or compute-heavy analytical work. - SMT2 (
sudo ppc64_cpu --smt=2): 64 hardware threads. A middle ground for mixed workloads. - SMT4 (
sudo ppc64_cpu --smt=4, default): 128 hardware threads. Typically favors high-concurrency OLTP, because a core can run instructions from another thread while one waits on memory.
These descriptions are general guidance. An SMT comparison you can run on your own system is described in the Benchmarking section; until then this guide uses the default (SMT4). Check the current mode:
beaker@hydra:~$ sudo ppc64_cpu --smt
Example output:
SMT=4
For the parallel settings, the logic is: max_worker_processes is the ceiling for all background workers, so it is set to the physical core count (32). max_parallel_workers cannot usefully exceed that ceiling. max_parallel_workers_per_gather = 4 keeps a single query from claiming more than an eighth of the pool, leaving room for concurrent queries. max_parallel_maintenance_workers = 8 speeds up index builds and similar maintenance without monopolizing the machine. These are starting points, not measured optima.
beaker@hydra:~$ sudo -u postgres tee /etc/postgresql/18/main/conf.d/91-parallel.conf > /dev/null << 'EOF'
# Parallel query tuning for POWER9 (32 physical cores / 128 threads)
max_worker_processes = 32 # background process ceiling (default: 8)
max_parallel_workers_per_gather = 4 # workers per Gather node (default: 2)
max_parallel_maintenance_workers = 8 # parallel index builds and VACUUM (default: 2)
max_parallel_workers = 32 # total parallel query workers (default: 8)
EOF
3. PostgreSQL 18 Asynchronous I/O (AIO)
Before PostgreSQL 18, backends issued synchronous reads and blocked until the kernel returned data. PostgreSQL 18 adds an AIO subsystem so a backend can queue several reads and keep working. The method is selected with io_method:
sync: Synchronous I/O as in earlier versions.worker(default): A pool of dedicated I/O worker processes (io_workers, default 3) performs reads on behalf of backends. Portable across platforms.io_uring: Backends submit reads directly through Linuxio_uringshared rings, which cuts system calls and context switches. Requires a build withliburingsupport (the PGDG build has it) and a kernel that permitsio_uringfor thepostgresuser.
What uses AIO in PostgreSQL 18? As of PostgreSQL 18, asynchronous reads are used by sequential scans, bitmap heap scans and
VACUUM. Other paths, notably plain index scans and writes, still use synchronous I/O (see the PostgreSQL 18 release notes). This matters for benchmark design: a benchmark made of index lookups, such aspgbench -S, exercises little AIO, while a large cold table scan exercises it heavily. The Benchmarking section covers both.
This guide keeps io_method at its default (worker) but raises io_workers from 3 to 16. On this machine three workers could not keep up with four parallel scan workers: a cold table scan took 28.9 s with 3 workers and 11.5 s with 16 (test C in the Benchmarking section).
beaker@hydra:~$ sudo -u postgres tee /etc/postgresql/18/main/conf.d/92-aio.conf > /dev/null << 'EOF'
# Asynchronous I/O
io_workers = 16 # I/O worker processes used by io_method = worker (default: 3)
EOF
io_uring is a one-line alternative (io_method = io_uring) if your kernel permits it. In the same scan it was within about 4% of worker with 16 workers (11.0 s against 11.5 s) and needs no worker processes, but both read at about 1.8 GB/s, so the difference is small. worker stays the default here because it is portable. The Benchmarking section compares all three methods with a separate test drop-in.
4. Check the Exact HugePage Requirement
Before the first start, PostgreSQL can report how many HugePages its shared memory needs. This works on a stopped cluster, and the command reads the configuration files you just wrote:
beaker@hydra:~$ sudo -u postgres /usr/lib/postgresql/18/bin/postgres -C shared_memory_size_in_huge_pages \
-D /hydra-ssd/pgsql/18/main -c config_file=/etc/postgresql/18/main/postgresql.conf
Example output:
16793
On the reference system this is just under the 17200 pages reserved, leaving a margin of about 2.4%, so no change is needed. If the number is well below your vm.nr_hugepages (17200), you can lower the sysctl to the reported value plus a small margin. If it is above, raise it before starting; with huge_pages = on a shortfall prevents startup.
First Start & Verification
Everything is now in place: the array is mounted, the HugePages are reserved, THP is off, the unit drop-in is loaded, and the configuration files are written. Start the cluster, which is the only start this guide needs:
beaker@hydra:~$ sudo systemctl start postgresql@18-main
beaker@hydra:~$ sudo pg_lsclusters
Example output:
Ver Cluster Port Status Owner Data directory Log file
18 main 5432 online postgres /hydra-ssd/pgsql/18/main /var/log/postgresql/postgresql-18-main.log
pg_lsclusters needs sudo here because the data directory is readable only by postgres. Without it, the Owner column shows <unknown> even though the cluster is running. If the start fails, check /var/log/postgresql/postgresql-18-main.log.
1. Check HugePage Usage
HugePages are claimed lazily. Pages the server has reserved but not yet touched appear as HugePages_Rsvd (and still count as free), and Rsvd shrinks as pages are used. So the figure to check is the number of pages in use or reserved, (HugePages_Total - HugePages_Free) + HugePages_Rsvd, which should be close to the 16,384 pages the buffer pool needs, plus overhead.
beaker@hydra:~$ grep -i hugepages_ /proc/meminfo
Example output:
HugePages_Total: 17200
HugePages_Free: 16841
HugePages_Rsvd: 16434
HugePages_Surp: 0
Here that is (17200 – 16841) + 16434 = 16,793 pages, or about 32.8 GB. That matches the 16793 reported by postgres -C in the previous section exactly.
2. Check NUMA Placement
The shared segment should be spread roughly evenly across both nodes (about 16 GB each). Compare the free HugePage counts per node before and after the start; both nodes should have dropped by a similar amount. You can also inspect the postmaster’s own mappings:
beaker@hydra:~$ cat /sys/devices/system/node/node*/hugepages/hugepages-2048kB/free_hugepages
beaker@hydra:~$ PID=$(sudo head -n1 /hydra-ssd/pgsql/18/main/postmaster.pid)
beaker@hydra:~$ sudo grep huge /proc/$PID/numa_maps
Example output:
8418
8423
3ff763200000 interleave:0,8 file=/anon_hugepage\040(deleted) huge dirty=356 mapmax=6 N0=181 N8=175 kernelpagesize_kB=2048
The two free counts are the two nodes (they add up to the 16841 free pages seen above). Look for interleave:0,8 on the large shared mapping, which confirms the NUMAPolicy=interleave setting is in effect, and for N0=... and N8=... of similar size. The counts are small here because HugePages are touched lazily (most of the buffer pool is still only reserved), so they grow as the server uses its shared memory. Small private allocations are not a reliable guide to balance, so judge placement by the shared segment.
3. Run the Full Checklist
# Cluster is online and using the SSD data directory
beaker@hydra:~$ sudo pg_lsclusters
# THP disabled
beaker@hydra:~$ cat /sys/kernel/mm/transparent_hugepage/enabled
# Scheduler and readahead settings
beaker@hydra:~$ grep . /sys/block/sd*/queue/scheduler
beaker@hydra:~$ sudo blockdev --getra /dev/md127p1
# Key settings, and which file each value came from
beaker@hydra:~$ sudo -u postgres psql -c "SELECT name, setting, source, sourcefile FROM pg_settings WHERE name IN ('listen_addresses', 'shared_buffers', 'huge_pages', 'max_parallel_workers', 'io_method', 'io_workers', 'effective_io_concurrency') ORDER BY name;"
# Systemd drop-in is in effect
beaker@hydra:~$ systemctl cat postgresql@18-main | grep -E 'NUMA|MEMLOCK|RequiresMountsFor'
Example output:
Ver Cluster Port Status Owner Data directory Log file
18 main 5432 online postgres /hydra-ssd/pgsql/18/main /var/log/postgresql/postgresql-18-main.log
always madvise [never]
/sys/block/sda/queue/scheduler:[none] mq-deadline
/sys/block/sdb/queue/scheduler:none [mq-deadline]
/sys/block/sdc/queue/scheduler:[none] mq-deadline
128
name | setting | source | sourcefile
--------------------------+---------+--------------------+---------------------------------------------------
effective_io_concurrency | 16 | default |
huge_pages | on | configuration file | /etc/postgresql/18/main/conf.d/90-memory-wal.conf
io_method | worker | default |
io_workers | 16 | configuration file | /etc/postgresql/18/main/conf.d/92-aio.conf
listen_addresses | * | configuration file | /etc/postgresql/18/main/postgresql.conf
max_parallel_workers | 32 | configuration file | /etc/postgresql/18/main/conf.d/91-parallel.conf
shared_buffers | 4194304 | configuration file | /etc/postgresql/18/main/conf.d/90-memory-wal.conf
(7 rows)
RequiresMountsFor=/etc/postgresql/%I /var/lib/postgresql/%I
RequiresMountsFor=/hydra-ssd
# Interleave buffer pool evenly across both NUMA sockets (avoids cross-bus latency)
NUMAPolicy=interleave
NUMAMask=all
LimitMEMLOCK=infinity
In the settings table, shared_buffers is reported in 8 kB blocks: 4194304 x 8 kB = 32 GB. Each value should come from the file this guide wrote it to, and io_method and effective_io_concurrency should show default with no source file. Any other source file means a stray setting elsewhere is overriding the guide’s, which is worth fixing before you go on.
Two other lines may look odd. One of the three drives (sdb here) keeps mq-deadline: that is the SATA OS drive, which the udev rule deliberately does not match, while the two RAID members show none. Your drive letters may differ, so compare against lsblk -d -o NAME,MODEL. The first RequiresMountsFor line comes from Debian’s own unit file; the second is the one added by this guide’s drop-in.
Provisioning the NetBox Role and Database (Optional)
The first application this server was built for is NetBox, which needs one database and one role that owns it. NetBox requires PostgreSQL 15 or later, so PostgreSQL 18 qualifies. This section uses the names from NetBox’s own documentation (a role and a database both called netbox); if you choose other names, use them here and in NetBox’s configuration.py.
The postgres superuser is deliberately left without a network password: it stays reachable only through the local peer socket, so there is no superuser password to guess over the network. The role’s password is set with \password, which avoids putting it in your shell or SQL history (NetBox’s documentation uses CREATE USER ... PASSWORD '...', which would record it in both).
beaker@hydra:~$ sudo -u postgres psql
postgres=# CREATE ROLE netbox WITH LOGIN;
postgres=# \password netbox
postgres=# CREATE DATABASE netbox OWNER netbox;
postgres=# \q
Because
netboxowns thenetboxdatabase, it already has full rights on it, includingCREATEon thepublicschema (PostgreSQL 15 and later). NetBox’s documentation also runsGRANT CREATE ON SCHEMA public TO netbox, which is redundant for the database owner, so it is omitted here.
From the machine that will run NetBox (it must be inside the subnet allowed in pg_hba.conf), confirm that the role can log in over the network and can create tables, which is what NetBox’s migrations need. This needs the psql client (the postgresql-client package) on that machine. Replace hydra in the command with this server’s hostname or IP address:
beaker@netbox:~$ psql --username netbox --password --host hydra netbox
netbox=> \conninfo
netbox=> CREATE TABLE connection_test (id integer);
netbox=> DROP TABLE connection_test;
netbox=> \q
Also confirm the database encoding is UTF8, which NetBox requires:
beaker@hydra:~$ sudo -u postgres psql -c "\l netbox"
Benchmarking (Optional)
This section is a sanity check of the finished system, not the point of the guide. It measures read throughput with pgbench, then lists the follow-up tests that would actually separate the AIO methods. The first-pass results are included with their limits stated plainly.
1. Methodology & Caveats
- Results are from single runs on one system. No variance is reported, so treat differences of a few percent as noise and larger differences as hypotheses until repeated.
pgbenchruns insimplequery mode (notprepared) and isSELECT-only (-S).- The
-s 2000dataset is about 30 GB including indexes, against 32 GB ofshared_buffers. That is marginal, so the runs are mostly served from memory and measure CPU, scheduling and memory behavior more than storage throughput. pgbenchruns on the same 128 hardware threads as the server it measures, so the client competes for CPU. Running it from a second machine over the 40GbE link removes that interference but adds network latency to every transaction. Either is legitimate; state which you used.- PostgreSQL 18 does not use AIO for the index lookups that
pgbench -Sperforms, so a difference betweenworkerandio_uringhere cannot be assumed to come from AIO. - Cache warmth and run order were not controlled for the first-pass runs below.
- An earlier repetition of Tests 1 to 3, run with the default of three I/O workers, gave 120,811, 118,144 and 322,609 TPS. The two 16-client results differ from the runs below by 11 to 12%, while the 64-client result differs by 0.4%.
pgbench -Sdoes not use AIO, soio_workersshould not explain this; treat 16-client differences of that size as noise.
2. Initialize the Test Database
A scale factor of 2000 generates 200 million pgbench_accounts rows.
beaker@hydra:~$ sudo -u postgres createdb benchdb
beaker@hydra:~$ sudo -u postgres pgbench -i -s 2000 benchdb
Example output:
dropping old tables...
NOTICE: table "pgbench_accounts" does not exist, skipping
NOTICE: table "pgbench_branches" does not exist, skipping
NOTICE: table "pgbench_history" does not exist, skipping
NOTICE: table "pgbench_tellers" does not exist, skipping
creating tables...
generating data (client-side)...
vacuuming...
creating primary keys...
done in 347.30 s (drop tables 0.00 s, create tables 0.02 s, client-side generate 278.18 s, vacuum 0.51 s, primary keys 68.60 s).
Client-side generation is single-stream and sustained about 719k rows/s. The primary key build took 68.6 s (about 2.92M keys/s) using maintenance_work_mem = 2GB and max_parallel_maintenance_workers = 8.
3. Test 1: Baseline worker Engine (SMT4, 16 Clients)
Confirm the engine, then run a 5-minute SELECT-only test. The flags are -c (client sessions), -j (pgbench worker threads), -T (duration in seconds) and -S (SELECT-only):
beaker@hydra:~$ sudo -u postgres psql -c "SHOW io_method;"
beaker@hydra:~$ sudo -u postgres pgbench -c 16 -j 4 -T 300 -S benchdb
Output:
pgbench (18.6 (Debian 18.6-1.pgdg13+2))
starting vacuum...end.
transaction type: <builtin: select only>
scaling factor: 2000
query mode: simple
number of clients: 16
number of threads: 4
maximum number of tries: 1
duration: 300 s
number of transactions actually processed: 40583961
number of failed transactions: 0 (0.000%)
latency average = 0.118 ms
initial connection time = 20.370 ms
tps = 135288.785080 (without initial connection time)
135,289 TPS, 0.118 ms average latency, 0 failures, with io_method = worker. To confirm the worker engine is active, count the I/O worker processes (there are none with io_uring):
beaker@hydra:~$ ps -eo pid,args | grep -i '[i]o worker' | wc -l
Example output:
16
Sixteen matches io_workers = 16 from the tuning section.
4. Test 2: io_uring Engine (SMT4, 16 Clients)
Enable io_uring with a drop-in file and restart, so that io_method is the only intended change from Test 1:
beaker@hydra:~$ sudo -u postgres tee /etc/postgresql/18/main/conf.d/99-aio-test.conf > /dev/null << 'EOF'
io_method = io_uring
EOF
beaker@hydra:~$ sudo systemctl restart postgresql@18-main
beaker@hydra:~$ sudo -u postgres psql -c "SHOW io_method;"
beaker@hydra:~$ sudo -u postgres pgbench -c 16 -j 4 -T 300 -S benchdb
Output:
pgbench (18.6 (Debian 18.6-1.pgdg13+2))
starting vacuum...end.
transaction type: <builtin: select only>
scaling factor: 2000
query mode: simple
number of clients: 16
number of threads: 4
maximum number of tries: 1
duration: 300 s
number of transactions actually processed: 39489504
number of failed transactions: 0 (0.000%)
latency average = 0.122 ms
initial connection time = 21.266 ms
tps = 131640.616204 (without initial connection time)
131,641 TPS, 0.122 ms average latency, 0 failures. Against Test 1 this is 2.7% lower throughput and 3.4% higher average latency, which is within the noise of single runs. That fits what is expected: index lookups do not use AIO in PostgreSQL 18, so io_uring has little to act on here. Note that the restart empties shared_buffers, so this run started with a cold buffer pool while Test 1 followed the data load directly; the two are not perfectly matched.
5. Test 3: io_uring, Higher Concurrency (SMT4, 64 Clients)
With io_uring still active, scale up to 64 clients and 8 pgbench threads:
beaker@hydra:~$ sudo -u postgres pgbench -c 64 -j 8 -T 300 -S benchdb
Output:
pgbench (18.6 (Debian 18.6-1.pgdg13+2))
starting vacuum...end.
transaction type: <builtin: select only>
scaling factor: 2000
query mode: simple
number of clients: 64
number of threads: 8
maximum number of tries: 1
duration: 300 s
number of transactions actually processed: 97174050
number of failed transactions: 0 (0.000%)
latency average = 0.198 ms
initial connection time = 79.812 ms
tps = 323998.160719 (without initial connection time)
323,998 TPS, 0.198 ms average latency, 0 failures. Going from 16 to 64 clients raised throughput about 2.5× while latency stayed under 0.2 ms. This is not an engine comparison, because there is no worker run at 64 clients.
6. Results Summary
| Benchmark Run | Engine (io_method) | Clients / Threads | Duration | Processed Transactions | Avg Latency | Throughput (TPS) | Notes |
|---|---|---|---|---|---|---|---|
| Test 1 | worker | 16 / 4 | 300 s | 40,583,961 | 0.118 ms | 135,288.79 | Baseline; first run after load |
| Test 2 | io_uring | 16 / 4 | 300 s | 39,489,504 | 0.122 ms | 131,640.62 | 2.7% lower TPS, 3.4% higher latency vs Test 1 (single runs; within noise) |
| Test 3 | io_uring | 64 / 8 | 300 s | 97,174,050 | 0.198 ms | 323,998.16 | +146.1% TPS vs Test 2; the client count changed, not just the engine |
What these results show: a cached, read-only workload on this system scales from about 135k to about 324k TPS as clients increase from 16 to 64, with no failures and sub-0.2 ms average latency.
What they do not show: that io_uring is faster than worker, or any effect of the scheduler, HugePages or SMT. None of those was varied in a controlled way.
7. Follow-up Tests
These tests would settle what the first pass could not. Record your results in a table of your own.
A. Repeat the cached comparison properly. The -s 2000 dataset is marginal for a 32 GB buffer pool, so use a scale that fits comfortably (-s 1500, about 22 GB), load it into shared_buffers, and confirm it is resident before timing anything. This repeats after every restart, because a restart empties shared_buffers:
beaker@hydra:~$ sudo -u postgres dropdb benchdb
beaker@hydra:~$ sudo -u postgres createdb benchdb
beaker@hydra:~$ sudo -u postgres pgbench -i -s 1500 benchdb
beaker@hydra:~$ sudo -u postgres psql benchdb << 'EOF'
CREATE EXTENSION IF NOT EXISTS pg_prewarm;
CREATE EXTENSION IF NOT EXISTS pg_buffercache;
SELECT pg_prewarm('pgbench_accounts');
SELECT pg_prewarm('pgbench_accounts_pkey');
SELECT c.relname,
pg_size_pretty(count(*) * 8192) AS buffered,
pg_size_pretty(pg_relation_size(c.oid)) AS size
FROM pg_buffercache b
JOIN pg_class c ON b.relfilenode = pg_relation_filenode(c.oid)
WHERE b.reldatabase = (SELECT oid FROM pg_database WHERE datname = current_database())
AND c.relname LIKE 'pgbench_accounts%'
GROUP BY c.oid, c.relname;
EOF
Example output (the initialization summary line, then the psql results):
done in 267.26 s (drop tables 0.00 s, create tables 0.02 s, client-side generate 212.68 s, vacuum 0.59 s, primary keys 53.97 s).
CREATE EXTENSION
CREATE EXTENSION
pg_prewarm
------------
2459017
(1 row)
pg_prewarm
------------
411289
(1 row)
relname | buffered | size
-----------------------+----------+---------
pgbench_accounts | 19 GB | 19 GB
pgbench_accounts_pkey | 3213 MB | 3213 MB
(2 rows)
buffered should match size for both relations, as it does here (about 22 GB in total, which fits in the 32 GB buffer pool). The pg_prewarm counts are 8 kB pages loaded. This helper switches engines with a single command (io_workers is ignored by io_uring):
beaker@hydra:~$ set_aio() {
printf 'io_method = %s\nio_workers = %s\n' "$1" "${2:-3}" \
| sudo -u postgres tee /etc/postgresql/18/main/conf.d/99-aio-test.conf > /dev/null
sudo systemctl restart postgresql@18-main
sudo -u postgres psql -Atc "SHOW io_method;"
}
The helper writes both settings to a test drop-in (99-aio-test.conf) that is read after the tuning section’s 92-aio.conf, so it overrides the tuned io_workers = 16 with its own default of 3 until you remove the file in the Cleanup step. Alternate engines (worker, io_uring, worker, io_uring, and so on) rather than running all of one engine first, so slow drift on the machine hits both equally. After each set_aio, prewarm, run a 60 s warm-up (-T 60) and discard it, then take three 300 s runs at 16 and 64 clients.
B. Cold sequential scan (exercises AIO). A full-table scan that must read the heap from disk uses asynchronous reads, so differences between engines here are attributable to the engine. Set the engine first with set_aio, then stop PostgreSQL, drop the OS page cache, and start it again (which also empties shared_buffers). Because abalance is 0 for every row, the filter matches nothing but still forces a full read:
beaker@hydra:~$ sudo systemctl stop postgresql@18-main
beaker@hydra:~$ sync; echo 3 | sudo tee /proc/sys/vm/drop_caches > /dev/null
beaker@hydra:~$ sudo systemctl start postgresql@18-main
beaker@hydra:~$ sudo -u postgres psql benchdb << 'EOF'
SET max_parallel_workers_per_gather = 0;
EXPLAIN (ANALYZE, BUFFERS, COSTS OFF)
SELECT count(*) FROM pgbench_accounts WHERE abalance <> 0;
EOF
Example output (one cold run with io_uring, no parallel workers):
SET
QUERY PLAN
-----------------------------------------------------------------------------------------
Aggregate (actual time=18965.554..18965.556 rows=1.00 loops=1)
Buffers: shared read=2459017
-> Seq Scan on pgbench_accounts (actual time=18965.492..18965.493 rows=0.00 loops=1)
Filter: (abalance <> 0)
Rows Removed by Filter: 150000000
Buffers: shared read=2459017
Planning:
Buffers: shared hit=41 read=14 dirtied=1
Planning Time: 13.405 ms
Execution Time: 19413.703 ms
(10 rows)
All 2,459,017 pages (about 19 GB) were read from disk in roughly 19 s, or about 1 GB/s. A single run says little by itself; use it to check that the plan reads the whole table (shared read equals the page count) and as a starting point for the comparisons below.
Before comparing engines, run the same query a second time without dropping the cache. The pages now come from the OS page cache, which shows how much of the cold time is CPU work rather than I/O:
Execution Time: 16375.469 ms
The warm run took 16.4 s against 19.4 s cold, so only about 3 s (16%) of the cold run was spent waiting on the disks. A single backend filters about 9 million rows per second here, which makes the single-process scan largely CPU-bound. That limits what an engine comparison can show: at most about 3 s of this scan can differ between engines. To make storage the bottleneck, repeat the comparison with parallel workers (max_parallel_workers_per_gather = 4 or higher), where several backends consume pages faster than one.
Take three cold runs each for sync, worker and io_uring, then repeat with max_parallel_workers_per_gather = 4. EXPLAIN reports Execution Time in milliseconds. This loop does all nine parallel runs, restarting PostgreSQL and dropping the cache before each one:
beaker@hydra:~$ for engine in sync worker io_uring; do
set_aio $engine
for run in 1 2 3; do
sudo systemctl stop postgresql@18-main
sync; echo 3 | sudo tee /proc/sys/vm/drop_caches > /dev/null
sudo systemctl start postgresql@18-main
echo -n "$engine run $run: "
sudo -u postgres psql benchdb -At \
-c "SET max_parallel_workers_per_gather = 4;" \
-c "EXPLAIN (ANALYZE, COSTS OFF) SELECT count(*) FROM pgbench_accounts WHERE abalance <> 0;" \
| grep 'Execution Time'
done
done
Results, 4 parallel workers, cold cache (worker used the default io_workers = 3):
| Engine | Run 1 | Run 2 | Run 3 | Mean | Read rate |
|---|---|---|---|---|---|
sync | 15.05 s | 15.53 s | 14.62 s | 15.07 s | 1.34 GB/s |
worker | 29.39 s | 27.68 s | 29.49 s | 28.86 s | 0.70 GB/s |
io_uring | 11.01 s | 11.03 s | 11.03 s | 11.02 s | 1.83 GB/s |
The read rate is the 20.1 GB table divided by the mean time. Here the engine does matter: io_uring is about 27% faster than sync and about 2.6 times faster than worker. The worker result is the surprise, since it is almost twice as slow as sync. With four scanning backends sharing only three I/O workers, the pool is a likely bottleneck, which is what test C checks, so do not read this as worker being slow in general. The io_uring runs differ by only 0.02 s, which suggests a hard limit somewhere in the storage path, not CPU. Treat the ranking as provisional: the engines ran one after another, not alternated, so slow drift on the machine could favor one of them.
C. Give worker a fair pool. The default of 3 I/O workers is small for a 128-thread machine, and comparing io_uring against an under-provisioned pool is not a fair fight. Repeat the worker runs with set_aio worker 16. Also compare effective_io_concurrency = 200 against the PostgreSQL 18 default of 16, since the old advice of 200 for SSDs predates AIO.
Results for the worker pool size, same cold 4-worker scan as test B:
| Engine | Run 1 | Run 2 | Run 3 | Mean | Read rate |
|---|---|---|---|---|---|
worker, io_workers = 3 | 29.39 s | 27.68 s | 29.49 s | 28.86 s | 0.70 GB/s |
worker, io_workers = 16 | 11.39 s | 11.45 s | 11.68 s | 11.51 s | 1.75 GB/s |
io_uring | 11.01 s | 11.03 s | 11.03 s | 11.02 s | 1.83 GB/s |
The pool size was the problem. With 16 I/O workers, worker is 2.5 times faster than with 3 and lands within about 4% of io_uring, which is consistent across the three runs but small. Both engines then read at roughly 1.8 GB/s, so the storage path, not the engine, is the limit. The practical lesson for this machine is that the default of 3 I/O workers is too small if you stay on worker.
Results for effective_io_concurrency, 16 against 200, same cold 4-worker scan, with io_workers = 16 and the two settings alternated within each engine:
| Engine | effective_io_concurrency | Run 1 | Run 2 | Run 3 | Mean |
|---|---|---|---|---|---|
worker | 16 (default) | 11.49 s | 11.77 s | 11.56 s | 11.61 s |
worker | 200 | 11.14 s | 11.11 s | 11.24 s | 11.16 s |
io_uring | 16 (default) | 11.02 s | 11.04 s | 11.05 s | 11.04 s |
io_uring | 200 | 11.01 s | 11.05 s | 11.05 s | 11.03 s |
io_uring is unaffected: all six runs fall within 0.04 s of each other, which fits a storage limit that the engine already reaches. worker gains about 4% with 200 (the ranges do not overlap), which brings it within about 1% of io_uring. That is a small gain on one workload, so this guide keeps the PostgreSQL 18 default of 16. If you stay on worker and your scans look like this one, 200 is a reasonable thing to try.
D. SMT scaling. With io_uring and 64 clients on the prewarmed dataset, compare SMT modes. The setting does not persist across reboots, but restore SMT4 afterwards anyway:
beaker@hydra:~$ sudo ppc64_cpu --smt=2 # then 1, then restore with: sudo ppc64_cpu --smt=4
beaker@hydra:~$ sudo -u postgres pgbench -c 64 -j 8 -T 300 -S benchdb
E. Optional: disk-bound pgbench -S. Initialize at -s 10000 (about 150 GB, larger than RAM) so random reads miss both caches, then repeat the worker vs io_uring comparison. Expect initialization to take roughly five times as long as the -s 2000 run.
8. Cleanup
beaker@hydra:~$ sudo -u postgres dropdb benchdb
beaker@hydra:~$ sudo rm /etc/postgresql/18/main/conf.d/99-aio-test.conf
beaker@hydra:~$ sudo systemctl restart postgresql@18-main
Removing the test drop-in returns io_method to the default and io_workers to the value from the tuning section (16).
Helpful Links
PostgreSQL
- PostgreSQL Official Debian Repository Guide
- PostgreSQL 18 Documentation: Resource Consumption (
io_method,io_workers) - PostgreSQL 18 Release Notes
- PostgreSQL Documentation: Managing Kernel Resources (Linux HugePages)
- PostgreSQL Documentation: Cluster Administration
- PostgreSQL Documentation: The pg_hba.conf File
- PostgreSQL Documentation: pgbench
- PostgreSQL Documentation: pg_prewarm
- PostgreSQL Documentation: pg_buffercache
Debian
Linux Kernel and System
- Linux Kernel Documentation: HugeTLB Pages
- Linux Kernel Documentation: Transparent Hugepage Support
- systemd.exec (
NUMAPolicy,NUMAMask,LimitMEMLOCK) - Linux RAID Wiki: A guide to mdadm
- Linux RAID Wiki: Write-intent bitmap
Hardware
NetBox
- NetBox Database Installation Documentation
- NetBox Required Configuration Settings (database settings)
Third-Party
- credativ: PostgreSQL 18 Asynchronous Disk I/O, a Deep Dive into the Implementation (article, December 2025)
Leave a Reply