Monitoring I/O statistics
Sometimes, in order to understand the performance of your system, especially in relation to the usage of hardware resources, you need to examine the I/O rates of the database and the objects contained within.
Getting ready
The pg_monitor
role will give you full access to I/O monitoring information.
How to do it...
Since PostgreSQL 16, the pg_stat_io
view is available to us for retrieving I/O statistics for the entire database server (including all databases). To see the running totals in bytes for each backend type, you can run the following query:
SELECT backend_type, reads * op_bytes AS bytes_read, writes * op_bytes AS bytes_written
FROM pg_stat_io;
You can expect output similar to this:
postgres=# SELECT backend_type, reads * op_bytes AS bytes_read, writes * op_bytes AS bytes_written FROM pg_stat_io;
backend_type | bytes_read | bytes_written
---------------------+------------+---------------
autovacuum launcher |...