blks_read/blks_hit stats - Mailing list pgsql-general

From Nigel Heron
Subject blks_read/blks_hit stats
Date
Msg-id 4DF8DFF7.10708@psycode.com
Whole thread Raw
Responses Re: blks_read/blks_hit stats
List pgsql-general
Hi everyone,

I'm playing with the stats views and functions to graph them in cacti..
Adding up *_blks_hit (heap, idx, toast and tidx) from pg_statio doesn't
match blks_hit in pg_stat_database.
Sometimes the sum is higher, sometimes lower. Do they have similar names
but represent different metrics?
Same issue with blks_read.

eg.
SELECT
SUM(pg_statio_all_tables.heap_blks_hit)::bigint +
SUM(pg_statio_all_tables.idx_blks_hit)::bigint +
SUM(pg_statio_all_tables.toast_blks_hit)::bigint +
SUM(pg_statio_all_tables.tidx_blks_hit)::bigint AS blks_hit
FROM pg_statio_all_tables;
   blks_hit
------------
  1275299563
(1 row)


SELECT blks_hit
FROM pg_stat_database
where datname='mydb';
   blks_hit
-----------
  674295210
(1 row)


here's 2 graphs from different databases on the same cluster (8.4.2).
first 4 stacked graph items are from pg_statio_all_tables and the red
line is from pg_stat_database.

blks_hit is way under the sum:
<http://www.psycode.com/gallery/d/88438-1/blks_read1.png>
blks_hit seems pretty close to the sum of table+idx (but no toast):
<http://www.psycode.com/gallery/d/88440-1/blks_read2.png>


thanks,
-nigel.


pgsql-general by date:

Previous
From: John R Pierce
Date:
Subject: Re: Setting up tablepace
Next
From: "Anibal David Acosta"
Date:
Subject: pgadmin "Running VACUUM recommended"