DEV Community

Dmitry Romanoff
Dmitry Romanoff

Posted on • Edited on

PostgreSQL. How to list the most IOPs-intensive queries?

To check the most IOPs-intensive queries on your PostgreSQL DB instance:

(1) Enable pg_stat_statements

(2) Set parameter of the DB instance

track_io_timing = 1

(3) Run the following query:

SELECT 
       (select datname from pg_database where oid=dbid) datname,
       query,
       blk_read_time + blk_write_time AS io_time
FROM pg_stat_statements
ORDER BY blk_read_time + blk_write_time DESC
LIMIT 20;
Enter fullscreen mode Exit fullscreen mode

ask_dima@yahoo.com

Top comments (0)