SELECT
sum(heap_blks_read) as heap_read,
sum(heap_blks_hit) as heap_hit,
sum(heap_blks_hit) / (sum(heap_blks_hit) + sum(heap_blks_read))*100 as ratio
FROM
pg_statio_user_tables;
===
#Index usage
select relname,seq_tup_read,idx_tup_fetch,
cast(idx_tup_fetch AS numeric / (idx_tup_fetch +seq_tup_read) AS idx_tup_pct
FROM pg_stat_user_tables
WHERE (idx_tup_fetch +seq_tup_read) > 0
order by idx_tup_pct
##Index cache usage
SELECT
sum(idx_blks_read) as idx_read,
sum(idx_blks_hit) as idx_hit,
(sum(idx_blks_hit) - sum(idx_blks_read)) / sum(idx_blks_hit) *100 as ratio
FROM
pg_statio_user_indexes;
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.