Thread: monitoring-stats.html documentation

monitoring-stats.html documentation

From
Robert Haas
Date:
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


Re: monitoring-stats.html documentation

From
Tom Lane
Date:
Robert Haas <robertmhaas@gmail.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


Re: monitoring-stats.html documentation

From
Robert Haas
Date:
On Sat, Apr 4, 2009 at 6:08 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Robert Haas <robertmhaas@gmail.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


Re: monitoring-stats.html documentation

From
Bruce Momjian
Date:
Tom Lane wrote:
> Robert Haas <robertmhaas@gmail.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@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +
Index: doc/src/sgml/monitoring.sgml
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/monitoring.sgml,v
retrieving revision 1.66
diff -c -c -r1.66 monitoring.sgml
*** doc/src/sgml/monitoring.sgml    28 Mar 2009 00:10:23 -0000    1.66
--- doc/src/sgml/monitoring.sgml    9 Apr 2009 22:31:00 -0000
***************
*** 924,931 ****

     <note>
      <para>
!      <function>blocks_fetched</function> minus
!      <function>blocks_hit</function> gives the number of kernel
       <function>read()</> calls issued for the table, index, or
       database; but the actual number of physical reads is usually
       lower due to kernel-level buffering.
--- 924,931 ----

     <note>
      <para>
!      <function>pg_stat_get_blocks_fetched</function> minus
!      <function>pg_stat_get_blocks_hit</function> gives the number of kernel
       <function>read()</> calls issued for the table, index, or
       database; but the actual number of physical reads is usually
       lower due to kernel-level buffering.

Re: monitoring-stats.html documentation

From
Bruce Momjian
Date:
Robert Haas wrote:
> On Sat, Apr 4, 2009 at 6:08 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> > Robert Haas <robertmhaas@gmail.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@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +
Index: doc/src/sgml/monitoring.sgml
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/monitoring.sgml,v
retrieving revision 1.67
diff -c -c -r1.67 monitoring.sgml
*** doc/src/sgml/monitoring.sgml    9 Apr 2009 22:32:02 -0000    1.67
--- doc/src/sgml/monitoring.sgml    10 Apr 2009 03:12:00 -0000
***************
*** 927,934 ****
       <function>pg_stat_get_blocks_fetched</function> minus
       <function>pg_stat_get_blocks_hit</function> gives the number of kernel
       <function>read()</> calls issued for the table, index, or
!      database; but the actual number of physical reads is usually
!      lower due to kernel-level buffering.
      </para>
     </note>

--- 927,935 ----
       <function>pg_stat_get_blocks_fetched</function> minus
       <function>pg_stat_get_blocks_hit</function> gives the number of kernel
       <function>read()</> calls issued for the table, index, or
!      database; the number of actual physical reads is usually
!      lower due to kernel-level buffering.  The <literal>*_blks_read</>
!      statistics columns uses this subtraction, i.e. fetched minus hit.
      </para>
     </note>


Re: monitoring-stats.html documentation

From
Robert Haas
Date:
On Thu, Apr 9, 2009 at 11:14 PM, Bruce Momjian <bruce@momjian.us> wrote:
> Done with attached patch;  good idea.

Bruce,

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

...Robert