Skip to content

Instantly share code, notes, and snippets.

@tobyhede
Created October 3, 2012 07:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tobyhede/3825480 to your computer and use it in GitHub Desktop.
Save tobyhede/3825480 to your computer and use it in GitHub Desktop.
Postgres Tuning

Cache Hit Ratio

SELECT 
  sum(heap_blks_read) as heap_read,
  sum(heap_blks_hit)  as heap_hit,
  (sum(heap_blks_hit) - sum(heap_blks_read)) / sum(heap_blks_hit) as ratio
FROM 
  pg_statio_user_tables;

Index Cache Hit Rate

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) as ratio
FROM 
  pg_statio_user_indexes;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment