Analyzing queries with high disk IO
0
votes
1
answer
3955
views
RDS Aurora PostgreSQL 10.14 instance db.r5.4xlarge.
I'm trying to figure out some high RDS IO costs in my machine.
I'm looking at the pg_stat_statements and asking whether the following query make sense:
SELECT rolname::regrole,
calls,
round((total_time / 1000 / 60)::numeric, 3) as total_minutes,
round(((total_time / 1000) / calls)::numeric, 3) as average_time_seconds,
rows,
userid,
regexp_replace(query, '[ \t\n]+', ' ', 'g') AS query_text,
100.0 * shared_blks_hit / nullif(shared_blks_hit + shared_blks_read, 0) AS hit_percent,
pg_size_pretty((shared_blks_hit + shared_blks_read) * 8192) AS total_memory_read
FROM pg_stat_statements
JOIN pg_roles r
ON r.oid = userid
WHERE calls > 1
AND rolname NOT LIKE '%backup'
AND rolname 'rdsadmin'
AND rolname 'rdsproxyadmin'
ORDER BY 8 asc nulls last
LIMIT 5;
According to the document hit_percent indicate how much data was fetch from the cache (shared_buffer or os kernel) vs. the total data - the higher the number, the better...
In my addition, I have total_memory_read which is the total of memory read from both disk and cache.
Here is an ouput I recieve
|rolname |calls|total_minutes|average_time_seconds|rows|userid|query_text |hit_percent |total_memory_read|
+----------+-----+-------------+--------------------+----+------+----------------------+------------------+-----------------+
|XXX |8 |4.278 |32.085 |256 |20550 |SELECT some_query ... |44.915182913169814|420 GB |
+----------+-----+-------------+--------------------+----+------+----------------------+------------------+-----------------+
My questions:
1. Does total_memory_read is really the amount of memory this 8 calls consume? It seems quite huge to be 420G
2. If I multiple (1-hit_percent) by total_memory_read do I get the number of GB it fetch from the disk (and eventually get disk IO of ~231)?
3. Are there any other suggestions on how to track high IO hogs?
Asked by Cowabunga
(145 rep)
Feb 2, 2022, 09:48 PM
Last activity: Feb 5, 2022, 01:15 AM
Last activity: Feb 5, 2022, 01:15 AM