Home Explore Blog CI



postgresql

6th chunk of `doc/src/sgml/pgbuffercache.sgml`
8ab1bf0ef6fef0229a9be1bc55d8186c9a371598b91a51480000000100000992
 <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> Function</title>
  <para>
   The <function>pg_buffercache_evict_relation()</function> function is very
   similar to the <function>pg_buffercache_evict()</function> function.  The
   difference is that the <function>pg_buffercache_evict_relation()</function>
   takes a relation identifier instead of buffer identifier.  It tries to
   evict all buffers for all forks in that relation.

   It returns the number of evicted buffers, flushed buffers and the number of
   buffers that could not be evicted.  Flushed buffers haven't necessarily
   been flushed by us, they might have been flushed by someone else.  The
   result is immediately out of date upon return, as buffers might immediately
   be read back in due to concurrent activity.  The function is intended for
   developer testing only.
  </para>
 </sect2>

 <sect2 id="pgbuffercache-pg-buffercache-evict-all">
  <title>The <structname>pg_buffercache_evict_all</structname> Function</title>
  <para>
   The <function>pg_buffercache_evict_all()</function> function is very
   similar to the <function>pg_buffercache_evict()</function> function.  The
   difference is, the <function>pg_buffercache_evict_all()</function> function
   does not take an argument; instead it tries to evict all buffers in the
   buffer pool.  It returns the number of evicted buffers, flushed buffers and
   the number of buffers that could not be evicted.  Flushed buffers haven't
   necessarily been flushed

Title: Buffer Eviction Functions
Summary
The pg_buffercache_evict(), pg_buffercache_evict_relation(), and pg_buffercache_evict_all() functions are used to evict buffers from the buffer pool, with varying scopes, including evicting a single buffer, all buffers for a relation, or all buffers in the pool, and return information on the number of evicted and flushed buffers, intended for developer testing only.