Re: monitoring-stats.html documentation

Lists: pgsql-hackers
From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: monitoring-stats.html documentation
Date: 2009-04-04 21:13:13
Message-ID: 603c8f070904041413j5a1880f9u22bae2e7d56543f4@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

http://developer.postgresql.org/pgdocs/postgres/monitoring-stats.html
says: "Note: blocks_fetched minus blocks_hit gives the number of
kernel read() calls issued for the table, index, or database; but the
actual number of physical reads is usually lower due to kernel-level
buffering." This seems to imply that anything that increases
blocks_hit should also increase blocks_fetched, but that doesn't seem
to match the actual behavior.

rhaas=# select heap_blks_read, heap_blks_hit from pg_statio_user_tables;
heap_blks_read | heap_blks_hit
----------------+---------------
4356 | 5618
(1 row)

rhaas=# select sum(1) from foo;
sum
--------
100000
(1 row)

rhaas=# select heap_blks_read, heap_blks_hit from pg_statio_user_tables;
heap_blks_read | heap_blks_hit
----------------+---------------
4356 | 6354
(1 row)

Obviously, if the note above were correct then (1) the number of
read() calls issue by the kernel would be negative and (2) accessing
the relation when it is fully cached would decreases the number of
read() calls previously issued.

...Robert


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: monitoring-stats.html documentation
Date: 2009-04-04 22:08:01
Message-ID: 23759.1238882881@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> http://developer.postgresql.org/pgdocs/postgres/monitoring-stats.html
> says: "Note: blocks_fetched minus blocks_hit gives the number of
> kernel read() calls issued for the table, index, or database; but the
> actual number of physical reads is usually lower due to kernel-level
> buffering." This seems to imply that anything that increases
> blocks_hit should also increase blocks_fetched, but that doesn't seem
> to match the actual behavior.

> rhaas=# select heap_blks_read, heap_blks_hit from pg_statio_user_tables;

It's talking about the underlying pg_stat_get_db_blocks_fetched()
function, not heap_blks_read which is just a view field defined as

pg_stat_get_blocks_fetched(C.oid) -
pg_stat_get_blocks_hit(C.oid) AS heap_blks_read,

Probably that sentence ought to spell out the full function name
instead of abbreviating.

regards, tom lane


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: monitoring-stats.html documentation
Date: 2009-04-05 02:02:34
Message-ID: 603c8f070904041902v262dba8aref387e55e3d2f4ac@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sat, Apr 4, 2009 at 6:08 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
>> http://developer.postgresql.org/pgdocs/postgres/monitoring-stats.html
>> says: "Note: blocks_fetched minus blocks_hit gives the number of
>> kernel read() calls issued for the table, index, or database; but the
>> actual number of physical reads is usually lower due to kernel-level
>> buffering."  This seems to imply that anything that increases
>> blocks_hit should also increase blocks_fetched, but that doesn't seem
>> to match the actual behavior.
>
>> rhaas=# select heap_blks_read, heap_blks_hit from pg_statio_user_tables;
>
> It's talking about the underlying pg_stat_get_db_blocks_fetched()
> function, not heap_blks_read which is just a view field defined as
>
>            pg_stat_get_blocks_fetched(C.oid) -
>                    pg_stat_get_blocks_hit(C.oid) AS heap_blks_read,
>
> Probably that sentence ought to spell out the full function name
> instead of abbreviating.

Oh, I see. I misread it, but I agree it could be written in a way
that would make it less likely to be misread. You could even add a
sentence explicitly mentioning that the views display the difference
of the two values.

...Robert


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: monitoring-stats.html documentation
Date: 2009-04-09 22:32:34
Message-ID: 200904092232.n39MWYk17954@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane wrote:
> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> > http://developer.postgresql.org/pgdocs/postgres/monitoring-stats.html
> > says: "Note: blocks_fetched minus blocks_hit gives the number of
> > kernel read() calls issued for the table, index, or database; but the
> > actual number of physical reads is usually lower due to kernel-level
> > buffering." This seems to imply that anything that increases
> > blocks_hit should also increase blocks_fetched, but that doesn't seem
> > to match the actual behavior.
>
> > rhaas=# select heap_blks_read, heap_blks_hit from pg_statio_user_tables;
>
> It's talking about the underlying pg_stat_get_db_blocks_fetched()
> function, not heap_blks_read which is just a view field defined as
>
> pg_stat_get_blocks_fetched(C.oid) -
> pg_stat_get_blocks_hit(C.oid) AS heap_blks_read,
>
> Probably that sentence ought to spell out the full function name
> instead of abbreviating.

Done.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

Attachment Content-Type Size
/rtmp/diff text/x-diff 1.0 KB

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: monitoring-stats.html documentation
Date: 2009-04-10 03:14:01
Message-ID: 200904100314.n3A3E1E18123@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Robert Haas wrote:
> On Sat, Apr 4, 2009 at 6:08 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> > Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> >> http://developer.postgresql.org/pgdocs/postgres/monitoring-stats.html
> >> says: "Note: blocks_fetched minus blocks_hit gives the number of
> >> kernel read() calls issued for the table, index, or database; but the
> >> actual number of physical reads is usually lower due to kernel-level
> >> buffering." ?This seems to imply that anything that increases
> >> blocks_hit should also increase blocks_fetched, but that doesn't seem
> >> to match the actual behavior.
> >
> >> rhaas=# select heap_blks_read, heap_blks_hit from pg_statio_user_tables;
> >
> > It's talking about the underlying pg_stat_get_db_blocks_fetched()
> > function, not heap_blks_read which is just a view field defined as
> >
> > ? ? ? ? ? ?pg_stat_get_blocks_fetched(C.oid) -
> > ? ? ? ? ? ? ? ? ? ?pg_stat_get_blocks_hit(C.oid) AS heap_blks_read,
> >
> > Probably that sentence ought to spell out the full function name
> > instead of abbreviating.
>
> Oh, I see. I misread it, but I agree it could be written in a way
> that would make it less likely to be misread. You could even add a
> sentence explicitly mentioning that the views display the difference
> of the two values.

Done with attached patch; good idea.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

Attachment Content-Type Size
/rtmp/diff text/x-diff 1.2 KB

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: monitoring-stats.html documentation
Date: 2009-04-10 03:39:29
Message-ID: 603c8f070904092039h1e8f720cr21c7c542f2b3d447@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, Apr 9, 2009 at 11:14 PM, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> Done with attached patch;  good idea.

Bruce,

You are a documentation-tuning machine... thanks.

...Robert