Home Explore Blog CI



postgresql

4th chunk of `doc/src/sgml/pgbuffercache.sgml`
e99a45b72e9e22ed712b84693174105fad145fcda5256b6d0000000100000fb5
 <entry role="catalog_table_entry"><para role="column_definition">
       <structfield>numa_node</structfield> <type>int</type>
      </para>
      <para>
       ID of <acronym>NUMA</acronym> node
      </para></entry>
     </row>

    </tbody>
   </tgroup>
  </table>

  <para>
   As <acronym>NUMA</acronym> node ID inquiry for each page requires memory pages
   to be paged-in, the first execution of this function can take a noticeable
   amount of time. In all the cases (first execution or not), retrieving this
   information is costly and querying the view at a high frequency is not recommended.
  </para>

  <warning>
    <para>
      When determining the <acronym>NUMA</acronym> node, the view touches
      all memory pages for the shared memory segment. This will force
      allocation of the shared memory, if it wasn't allocated already,
      and the memory may get allocated in a single <acronym>NUMA</acronym>
      node (depending on system configuration).
    </para>
  </warning>

 </sect2>

 <sect2 id="pgbuffercache-summary">
  <title>The <function>pg_buffercache_summary()</function> Function</title>

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

  <table id="pgbuffercache-summary-columns">
   <title><function>pg_buffercache_summary()</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>buffers_used</structfield> <type>int4</type>
      </para>
      <para>
       Number of used shared buffers
      </para></entry>
     </row>

     <row>
      <entry role="catalog_table_entry"><para role="column_definition">
       <structfield>buffers_unused</structfield> <type>int4</type>
      </para>
      <para>
       Number of unused shared buffers
      </para></entry>
     </row>

     <row>
      <entry role="catalog_table_entry"><para role="column_definition">
       <structfield>buffers_dirty</structfield> <type>int4</type>
      </para>
      <para>
       Number of dirty shared buffers
      </para></entry>
     </row>

     <row>
      <entry role="catalog_table_entry"><para role="column_definition">
       <structfield>buffers_pinned</structfield> <type>int4</type>
      </para>
      <para>
       Number of pinned shared buffers
      </para></entry>
     </row>

     <row>
      <entry role="catalog_table_entry"><para role="column_definition">
       <structfield>usagecount_avg</structfield> <type>float8</type>
      </para>
      <para>
       Average usage count of used shared buffers
      </para></entry>
     </row>
    </tbody>
   </tgroup>
  </table>

  <para>
   The <function>pg_buffercache_summary()</function> function returns a
   single 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

Title: Buffer Cache Summary and Usage Counts Functions
Summary
The pg_buffercache_summary() function provides a summary of shared buffer usage, including counts of used, unused, dirty, and pinned buffers, as well as average usage counts, while the pg_buffercache_usage_counts() function offers detailed usage counts, both functions provide cheaper alternatives to querying the pg_buffercache view, but may have minor inaccuracies due to lack of buffer manager locks and concurrent activity.