PostgreSQL 19 brings some updates to asynchronous I/O. One big change is how it handles the I/O worker processes. Older versions like PostgreSQL 18 used a fixed number of workers. Postgresql 19 lets the server change the worker count within limits you can set, all based on what is needed. If you are checking out PostgreSQL 19 or seeing how it stacks up against releases, this shift is worth knowing. In this article, we will look at the config settings, watch the workers in action while a workload runs, and see how PostgreSQL 18 and PostgreSQL 19 deal with I/O workers in use.
Before that, check the current postgres clusters in your system by using the command below.
cybrosys@cybrosys:~$ pg_lsclusters
Result:
Ver Cluster Port Status Owner Data directory Log file
18 main 5432 online postgres /var/lib/postgresql/18/main /var/log/postgresql/postgresql-18-main.log
19 main 5433 online postgres /var/lib/postgresql/19/main /var/log/postgresql/postgresql-19-main.log
Check the version number of postgres 18.
postgres=# select version();
Result:
version
-------------------------------------------------------------------------------------------------------------------------------------
PostgreSQL 18.6 (Ubuntu 18.6-1.pgdg22.04+2) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0, 64-bit
(1 row)
In PostgreSQL 18, we can see the parameter named io_workers. This parameter defines the number of background processes related to the asynchronous i/o infrastructure.
Now, check the current value of the parameter named io_workers in postgresql 18.
postgres=# show io_workers ;
Result:
io_workers
------------
3
(1 row)
In PostgreSQL 18, we can see this parameter and its related metadata from pg_settings. The default value for this parameter is 3.
Check the metadata of this parameter from the pg_settings catalogue like this.
postgres=# select * from pg_settings where name = 'io_workers';
Result:
-[ RECORD 1 ]---+-----------------------------------------------------
name | io_workers
setting | 3
unit |
category | Resource Usage / I/O
short_desc | Number of IO worker processes, for io_method=worker.
extra_desc |
context | sighup
vartype | integer
source | default
min_val | 1
max_val | 32
enumvals |
boot_val | 3
reset_val | 3
sourcefile |
sourceline |
pending_restart | f
We can set up to 32 workers for this parameter.
Now, check the value for the parameter named io_method.
postgres=# show io_method ;
Result:
io_method
-----------
worker
(1 row)
Now, check this parameter’s metadata from pg_settings like this.
postgres=# select * from pg_settings where name = 'io_method';
Result:
-[ RECORD 1 ]---+---------------------------------------------------
name | io_method
setting | worker
unit |
category | Resource Usage / I/O
short_desc | Selects the method for executing asynchronous I/O.
extra_desc |
context | postmaster
vartype | enum
source | default
min_val |
max_val |
enumvals | {sync,worker,io_uring}
boot_val | worker
reset_val | worker
sourcefile |
sourceline |
pending_restart | f
Postgresql 18 supports mainly three types of methods related to asynchronous i/o.
Sync :
- The backend process performs disk reads itself and waits until each read completes.
- No asynchronous I/O or helper processes are used.
- Simplest method, but provides the lowest I/O performance.
Worker:
- The backend submits I/O requests to dedicated I/O worker processes.
- Workers perform the disk reads in parallel while the backend can continue other work.
- Default in PostgreSQL 18; it offers better performance and works on all supported platforms.
io_uring:
- The backend submits I/O requests directly to the Linux kernel using the io_uring interface.
- No PostgreSQL I/O worker processes are needed.
- Provides the highest performance with the lowest overhead, but is available only on supported Linux kernels.4
Now, let’s explore the new changes in io workers in PostgreSQL 19.
Check the version number of postgres 19.
postgres=# select version();
Result:
version
-----------------------------------------------------------------------------------------------------
PostgreSQL 19.0 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0, 64-bit
(1 row)
In PostgreSQL 19, the working of io_workers has changed. There is no parameter named io_workers in Postgresql 19. Instead, we have the parameters named io_min_workers and io_max_workers.
Check the value for the parameter named io_min_workers.
postgres=# show io_min_workers ;
Result:
io_min_workers
----------------
2
(1 row)
The default value for this parameter is 2.
Now check the value for the parameter named io_max_workers.
postgres=# show io_max_workers ;
Result:
io_max_workers
----------------
8
(1 row)
The default value is 8.
Now check the io_min_workers metadata from pg_settings like this.
postgres=# select * from pg_settings where name = 'io_min_workers';
Result:
-[ RECORD 1 ]---+--------------------------------------------------------------
name | io_min_workers
setting | 2
unit |
category | Resource Usage / I/O
short_desc | Minimum number of I/O worker processes, for io_method=worker.
extra_desc |
context | sighup
vartype | integer
source | default
min_val | 1
max_val | 32
enumvals |
boot_val | 2
reset_val | 2
sourcefile |
sourceline |
pending_restart | f
Check the io_max_workers metadata from pg_settings like this.
postgres=# select * from pg_settings where name = 'io_max_workers';
Result:
-[ RECORD 1 ]---+--------------------------------------------------------------
name | io_max_workers
setting | 8
unit |
category | Resource Usage / I/O
short_desc | Maximum number of I/O worker processes, for io_method=worker.
extra_desc |
context | sighup
vartype | integer
source | default
min_val | 1
max_val | 32
enumvals |
boot_val | 8
reset_val | 8
sourcefile |
sourceline |
pending_restart | f
Check the value of the parameter named io_method.
postgres=# show io_method ;
Result:
io_method
-----------
worker
(1 row)
Now, check this parameter’s metadata from pg_settings like this.
postgres=# select * from pg_settings where name = 'io_method';
Result:
-[ RECORD 1 ]---+---------------------------------------------------
name | io_method
setting | worker
unit |
category | Resource Usage / I/O
short_desc | Selects the method for executing asynchronous I/O.
extra_desc |
context | postmaster
vartype | enum
source | default
min_val |
max_val |
enumvals | {sync,worker}
boot_val | worker
reset_val | worker
sourcefile |
sourceline |
pending_restart | f
Now, execute some query examples based on io workers usage in postgresql 18 and 19.
Create a sample table and insert huge values.
CREATE TABLE io_test AS
SELECT g AS id, md5(g::text) AS a, repeat('x', 200) AS pad
FROM generate_series(1, 5000000) g;
Check the size of the table.
SELECT pg_size_pretty(pg_relation_size('io_test'));Result:
pg_size_pretty
----------------
1347 MB
(1 row)
Create a .sql file and set the parallel workers per gather parameter to 0 and the select query to check the total records of the table named io_test.
cat > /tmp/io_scan.sql <<'EOF'
SET max_parallel_workers_per_gather = 0;
SELECT count(*) FROM io_test;
EOF
Now, use the pgbench command like this.
pgbench -n -f /tmp/io_scan.sql -c 16 -j 4 -T 120 -p 5432 postgres
pgbench is used to repeatedly execute the SQL workload with multiple concurrent clients to benchmark PostgreSQL performance and measure I/O throughput.
-n - Runs the benchmark without performing database vacuum checks.- -c 16 - Creates 16 concurrent client connections to simulate multiple users running the query at the same time.
- -j 4 - Uses 4 pgbench worker threads to manage those 16 client connections efficiently.
- -T 120 - Runs the benchmark continuously for 120 seconds to collect stable performance results.
- -p 5432 - Connects to PostgreSQL version 18 running on port 5432.
- postgres - The database where the test is executed.
pgbench -n -f /tmp/io_scan.sql -c 16 -j 4 -T 120 -p 5433 postgres
Now, execute the same pgbench commands in the other port number named 5433, where the postgres version 19 is running.
Now, execute the below queries in PostgreSQL version 18.
SELECT now()::time(0) AS t,
count(*) AS io_workers,
count(*) FILTER (WHERE wait_event = 'IoWorkerMain') AS idle,
count(*) FILTER (WHERE wait_event IS DISTINCT FROM 'IoWorkerMain') AS busy,
string_agg(pid::text, ',' ORDER BY backend_start) AS pids
FROM pg_stat_activity
WHERE backend_type = 'io worker'
\watch 1
Result:
Thursday 26 November 2026 11:31:48 PM (every 1s)
t | io_workers | idle | busy | pids
----------+------------+------+------+----------------
23:31:49 | 3 | 3 | 0 | 1224,1227,1228
(1 row)
Thursday 26 November 2026 11:31:49 PM (every 1s)
t | io_workers | idle | busy | pids
----------+------------+------+------+----------------
23:31:50 | 3 | 3 | 0 | 1224,1227,1228
(1 row)
Thursday 26 November 2026 11:31:50 PM (every 1s)
t | io_workers | idle | busy | pids
----------+------------+------+------+----------------
23:31:51 | 3 | 3 | 0 | 1224,1227,1228
(1 row)
Here, we can see the count of io_workers used in the query execution in PostgreSQL 18. The default value of io_workers is 3.
Now, execute the query below and check the current background activities from pg_stat_activity based on io_workers.
SELECT pid,
backend_start,
now() - backend_start AS age,
backend_start - lag(backend_start) OVER (ORDER BY backend_start) AS gap_after_previous,
wait_event_type, wait_event
FROM pg_stat_activity
WHERE backend_type = 'io worker'
ORDER BY backend_start;
Result:
pid | backend_start | age | gap_after_previous | wait_event_type | wait_event
------+----------------------------------+-----------------+--------------------+-----------------+--------------
1224 | 2026-11-26 08:57:58.651735+05:30 | 14:35:44.4215 | | Activity | IoWorkerMain
1227 | 2026-11-26 08:57:58.653625+05:30 | 14:35:44.41961 | 00:00:00.00189 | Activity | IoWorkerMain
1228 | 2026-11-26 08:57:58.655293+05:30 | 14:35:44.417942 | 00:00:00.001668 | Activity | IoWorkerMain
(3 rows)
Here, we can see that the three background processes related to the io_workers are executing in postgres.
Now, use the watch command to see the next results from the same query.
\watch
Result:
Thursday 26 November 2026 11:33:53 PM (every 2s)
pid | backend_start | age | gap_after_previous | wait_event_type | wait_event
------+----------------------------------+-----------------+--------------------+-----------------+--------------
1224 | 2026-11-26 08:57:58.651735+05:30 | 14:35:55.280096 | | IO | DataFileRead
1227 | 2026-11-26 08:57:58.653625+05:30 | 14:35:55.278206 | 00:00:00.00189 | IO | DataFileRead
1228 | 2026-11-26 08:57:58.655293+05:30 | 14:35:55.276538 | 00:00:00.001668 | |
(3 rows)
Thursday 26 November 2026 11:33:55 PM (every 2s)
pid | backend_start | age | gap_after_previous | wait_event_type | wait_event
------+----------------------------------+-----------------+--------------------+-----------------+--------------
1224 | 2026-11-26 08:57:58.651735+05:30 | 14:35:57.282515 | | |
1227 | 2026-11-26 08:57:58.653625+05:30 | 14:35:57.280625 | 00:00:00.00189 | |
1228 | 2026-11-26 08:57:58.655293+05:30 | 14:35:57.278957 | 00:00:00.001668 | IO | DataFileRead
(3 rows)
Here, we can see that at most 3 background activities related to io workers are currently executing.
Now, check the records from the catalogue named pg_aios.
SELECT state, operation, count(*)
FROM pg_aios
GROUP BY 1, 2
ORDER BY 3 DESC;
Result:
Thursday 26 November 2026 11:34:59 PM (every 2s)
state | operation | count
------------------+-----------+-------
SUBMITTED | readv | 49
COMPLETED_SHARED | readv | 14
COMPLETED_IO | readv | 1
(3 rows)
Thursday 26 November 2026 11:35:01 PM (every 2s)
state | operation | count
------------------+-----------+-------
SUBMITTED | readv | 46
COMPLETED_SHARED | readv | 26
HANDED_OUT | | 1
COMPLETED_IO | readv | 1
(4 rows)
The pg_aios output shows the status of asynchronous I/O requests during the workload.SUBMITTED - I/O requests that PostgreSQL has sent but are still waiting to be completed.
COMPLETED_SHARED - Reads completed using data already available in PostgreSQL shared buffers.
COMPLETED_IO - Reads completed after actual I/O from storage.
HANDED_OUT - Completed I/O requests that have been returned to the requesting backend process.
Now, execute the queries below in postgres version 19.
SELECT now()::time(0) AS t,
count(*) AS io_workers,
count(*) FILTER (WHERE wait_event = 'IoWorkerMain') AS idle,
count(*) FILTER (WHERE wait_event IS DISTINCT FROM 'IoWorkerMain') AS busy,
string_agg(pid::text, ',' ORDER BY backend_start) AS pids
FROM pg_stat_activity
WHERE backend_type = 'io worker'
\watch 1
Result:
Thursday 26 November 2026 11:31:53 PM (every 1s)
t | io_workers | idle | busy | pids
----------+------------+------+------+-----------
23:31:53 | 2 | 2 | 0 | 1276,1277
(1 row)
Thursday 26 November 2026 11:31:54 PM (every 1s)
t | io_workers | idle | busy | pids
----------+------------+------+------+---------------------------------------------------
23:31:54 | 7 | 0 | 7 | 1276,1277,1118668,1118681,1118682,1118683,1118685
(1 row)
Thursday 26 November 2026 11:31:55 PM (every 1s)
t | io_workers | idle | busy | pids
----------+------------+------+------+-----------------------------------------------------------
23:31:55 | 8 | 6 | 2 | 1276,1277,1118668,1118681,1118682,1118683,1118685,1118713
(1 row)
Here, we can see that the io workers count is increased from 2 to 8. This is because in postgres 19 the io workers are actually applied automatically.
We can set the minimum and maximum workers for the asynchronous i/o based on the parameters named io_min_workers and io_max_workers.
Now, check the current background activities from pg_stat_activity based on io_workers in postgresql 19.
SELECT pid,
backend_start,
now() - backend_start AS age,
backend_start - lag(backend_start) OVER (ORDER BY backend_start) AS gap_after_previous,
wait_event_type, wait_event
FROM pg_stat_activity
WHERE backend_type = 'io worker'
ORDER BY backend_start;
Result:
pid | backend_start | age | gap_after_previous | wait_event_type | wait_event
---------+----------------------------------+-----------------+--------------------+-----------------+--------------
1276 | 2026-11-26 08:57:58.92329+05:30 | 14:35:45.859537 | | Activity | IoWorkerMain
1277 | 2026-11-26 08:57:58.924137+05:30 | 14:35:45.85869 | 00:00:00.000847 | Activity | IoWorkerMain
1118668 | 2026-11-26 23:31:53.735619+05:30 | 00:01:51.047208 | 14:33:54.811482 | Activity | IoWorkerMain
1118681 | 2026-11-26 23:31:53.840144+05:30 | 00:01:50.942683 | 00:00:00.104525 | Activity | IoWorkerMain
1118682 | 2026-11-26 23:31:53.938504+05:30 | 00:01:50.844323 | 00:00:00.09836 | Activity | IoWorkerMain
1118683 | 2026-11-26 23:31:54.048213+05:30 | 00:01:50.734614 | 00:00:00.109709 | Activity | IoWorkerMain
1118685 | 2026-11-26 23:31:54.138273+05:30 | 00:01:50.644554 | 00:00:00.09006 | Activity | IoWorkerMain
(7 rows)
Here, we can see that nearly 7 io_woker related background activities are executed here.
Now, execute the watch command to see the upcoming results.
postgres=# \watch
Result:
Thursday 26 November 2026 11:33:56 PM (every 2s)
pid | backend_start | age | gap_after_previous | wait_event_type | wait_event
---------+----------------------------------+-----------------+--------------------+-----------------+--------------
1276 | 2026-11-26 08:57:58.92329+05:30 | 14:35:57.779418 | | Activity | IoWorkerMain
1277 | 2026-11-26 08:57:58.924137+05:30 | 14:35:57.778571 | 00:00:00.000847 | Activity | IoWorkerMain
1118668 | 2026-11-26 23:31:53.735619+05:30 | 00:02:02.967089 | 14:33:54.811482 | Activity | IoWorkerMain
1118681 | 2026-11-26 23:31:53.840144+05:30 | 00:02:02.862564 | 00:00:00.104525 | Activity | IoWorkerMain
1118682 | 2026-11-26 23:31:53.938504+05:30 | 00:02:02.764204 | 00:00:00.09836 | Activity | IoWorkerMain
1118683 | 2026-11-26 23:31:54.048213+05:30 | 00:02:02.654495 | 00:00:00.109709 | Activity | IoWorkerMain
(6 rows)
We can see that the count of background activities related to the io_workers is changing dynamically.
The comparison shows that PostgreSQL 18 and PostgreSQL 19 manage I/O workers in different ways. PostgreSQL 18 starts with a fixed number of workers defined by the io_workers parameter, whereas PostgreSQL 19 introduces io_min_workers and io_max_workers, allowing the server to increase or reduce the number of workers according to workload requirements.
By observing system views and running the same workload on both versions, the difference in worker allocation becomes clear. These changes give PostgreSQL 19 greater flexibility and help the database use available resources more efficiently during asynchronous I/O operations.