Home Explore Blog CI



postgresql

5th chunk of `doc/src/sgml/pgbuffercache.sgml`
3f38a9477731ef7e3712a30fb664568f23f4c9cf85c129ed0000000100000f95
 row summarizing the state of all shared buffers. Similar and more
   detailed information is provided by the
   <structname>pg_buffercache</structname> view, but
   <function>pg_buffercache_summary()</function> is significantly cheaper.
  </para>

  <para>
   Like the <structname>pg_buffercache</structname> view,
   <function>pg_buffercache_summary()</function> does not acquire buffer
   manager locks. Therefore concurrent activity can lead to minor inaccuracies
   in the result.
  </para>
 </sect2>

 <sect2 id="pgbuffercache-usage-counts">
  <title>The <function>pg_buffercache_usage_counts()</function> Function</title>

  <para>
   The definitions of the columns exposed by the function are shown in
   <xref linkend="pgbuffercache_usage_counts-columns"/>.
  </para>

  <table id="pgbuffercache_usage_counts-columns">
   <title><function>pg_buffercache_usage_counts()</function> Output Columns</title>
   <tgroup cols="1">
    <thead>
     <row>
      <entry role="catalog_table_entry"><para role="column_definition">
       Column Type
      </para>
      <para>
       Description
      </para></entry>
     </row>
    </thead>

    <tbody>
     <row>
      <entry role="catalog_table_entry"><para role="column_definition">
       <structfield>usage_count</structfield> <type>int4</type>
      </para>
      <para>
       A possible buffer usage count
      </para></entry>
     </row>

     <row>
      <entry role="catalog_table_entry"><para role="column_definition">
       <structfield>buffers</structfield> <type>int4</type>
      </para>
      <para>
       Number of buffers with the usage count
      </para></entry>
     </row>

     <row>
      <entry role="catalog_table_entry"><para role="column_definition">
       <structfield>dirty</structfield> <type>int4</type>
      </para>
      <para>
       Number of dirty buffers with the usage count
      </para></entry>
     </row>

     <row>
      <entry role="catalog_table_entry"><para role="column_definition">
       <structfield>pinned</structfield> <type>int4</type>
      </para>
      <para>
       Number of pinned buffers with the usage count
      </para></entry>
     </row>
    </tbody>
   </tgroup>
  </table>

  <para>
   The <function>pg_buffercache_usage_counts()</function> function returns a
   set of rows summarizing the states of all shared buffers, aggregated over
   the possible usage count values.  Similar and more detailed information is
   provided by the <structname>pg_buffercache</structname> view, but
   <function>pg_buffercache_usage_counts()</function> is significantly cheaper.
  </para>

  <para>
   Like the <structname>pg_buffercache</structname> view,
   <function>pg_buffercache_usage_counts()</function> does not acquire buffer
   manager locks. Therefore concurrent activity can lead to minor inaccuracies
   in the result.
  </para>
 </sect2>

 <sect2 id="pgbuffercache-pg-buffercache-evict">
  <title>The <function>pg_buffercache_evict()</function> Function</title>
  <para>
   The <function>pg_buffercache_evict()</function> function takes a buffer
   identifier, as shown in the <structfield>bufferid</structfield> column of
   the <structname>pg_buffercache</structname> view.  It returns information
   about whether the buffer was evicted and flushed.  The buffer_evicted
   column is true on success, and false if the buffer wasn't valid, if it
   couldn't be evicted because it was pinned, or if it became dirty again
   after an attempt to write it out.  The buffer_flushed column is true if the
   buffer was flushed.  This does not necessarily mean that buffer was flushed
   by us, it might be flushed by someone else.  The result is immediately out
   of date upon return, as the buffer might become valid again at any time due
   to concurrent activity. The function is intended for developer testing
   only.
  </para>
 </sect2>

 <sect2 id="pgbuffercache-pg-buffercache-evict-relation">
  <title>The <structname>pg_buffercache_evict_relation</structname>

Title: pg_buffercache_usage_counts and pg_buffercache_evict Functions
Summary
The pg_buffercache_usage_counts() function returns a set of rows summarizing shared buffer states aggregated by usage count, while the pg_buffercache_evict() function evicts a specified buffer and returns information on whether it was successfully evicted and flushed, with both functions providing cheaper alternatives to querying the pg_buffercache view but potentially having minor inaccuracies due to concurrent activity.