April 2018
Intermediate to advanced
508 pages
15h 22m
English
The same basic I/O statistics available for indexes are also available broken down for each index:
pgbench=# SELECT indexrelname,cast(idx_blks_hit as numeric) / (idx_blks_hit + idx_blks_read) AS hit_pct,idx_blks_hit,idx_blks_read FROM pg_statio_user_indexes WHERE (idx_blks_hit + idx_blks_read)>0 ORDER BY hit_pct; indexrelname | hit_pct | idx_blks_hit | idx_blks_read
----------------------+---------+--------------+--------------
pgbench_branches_pkey | 0.33333 | 1 | 2
pgbench_tellers_pkey | 0.33333 | 1 | 2
pgbench_accounts_pkey | 0.99945 | 405206 | 221
Indexes tend to be better cached than their underlying tables. If they're not, that's another hint that you might not be indexing your data properly.
Read now
Unlock full access