Sub topic 12
I/O Concurrency and Prefetching Settings
Assume you can run basic SQL, read an EXPLAIN plan, and reload PostgreSQL configuration. You should also know whether the database uses local SSD, network storage, or a hard disk.
What I/O concurrency controls
effective_io_concurrency tells PostgreSQL how many read operations the storage system can handle at the same time. PostgreSQL mainly uses this setting to prefetch blocks during bitmap heap scans. Prefetching means requesting likely-needed blocks before the query reaches them.
This setting does not create database connections or query workers. It changes how PostgreSQL issues read requests. A value of 0 disables asynchronous prefetching. The default is conservative and may be too low for fast storage.
maintenance_io_concurrency applies a similar idea to maintenance tasks such as VACUUM and index cleanup on PostgreSQL versions that provide this setting. Check pg_settings on your server before using it.
SELECT name, setting, unit, context, pending_restart
FROM pg_settings
WHERE name IN ('effective_io_concurrency', 'maintenance_io_concurrency');The useful value depends on the complete I/O path:
- A hard disk usually benefits from a small value because random requests compete for the disk head.
- SSDs and NVMe devices can handle more concurrent requests.
- Network storage may support concurrency, but network latency, bandwidth, and provider limits matter.
- A high value cannot make saturated storage faster. It can increase queueing and contention.
How prefetching appears in a query
Bitmap scans first collect matching block locations in a bitmap. PostgreSQL can then issue reads for several future blocks while processing the current ones.
effective_io_concurrency matters most when a query performs many heap reads. It has little benefit when all required pages are already cached, when a sequential scan is already efficient, or when the query returns very few rows.
Use EXPLAIN (ANALYZE, BUFFERS) to find a suitable test query:
EXPLAIN (ANALYZE, BUFFERS)
SELECT *
FROM orders
WHERE customer_id = 42;Look for a Bitmap Heap Scan and compare execution time, buffer reads, and system I/O while testing different values. Keep the query, data, cache state, and workload as similar as possible.
Choosing and changing a value
Do not choose a value from the device's advertised maximum queue depth alone. PostgreSQL, the operating system, the filesystem, and the storage service all add limits. Start with a modest value, measure representative queries, and increase it only when read latency or throughput improves.
| Storage type | Starting approach |
|---|---|
| Hard disk | Keep the value low and test carefully |
| SSD or NVMe | Test a moderate value, then compare workload results |
| Network storage | Test against provider latency and bandwidth limits |
You can test a session-local change without affecting other sessions:
SET effective_io_concurrency = 16;
EXPLAIN (ANALYZE, BUFFERS)
SELECT *
FROM orders
WHERE customer_id = 42;After testing, make a persistent change through the configuration method used by your environment. Verify context and pending_restart in pg_settings; do not assume every setting has the same reload behavior.
Exercise
A query uses a Bitmap Heap Scan, but increasing effectiveioconcurrency makes the server's I/O queue much longer without reducing execution time. What should you do?
Show answer
Revert to the lower value. The storage path is already saturated or does not benefit from more concurrent prefetch requests.