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 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-sample-output">
<title>Sample Output</title>
<screen>
regression=# SELECT n.nspname, c.relname, count(*) AS buffers
FROM pg_buffercache b JOIN pg_class c
ON b.relfilenode = pg_relation_filenode(c.oid) AND
b.reldatabase IN (0, (SELECT oid FROM pg_database
WHERE datname = current_database()))
JOIN pg_namespace n ON n.oid = c.relnamespace
GROUP BY n.nspname, c.relname
ORDER BY 3 DESC
LIMIT 10;
nspname | relname | buffers
------------+------------------------+---------
public | delete_test_table | 593
public | delete_test_table_pkey | 494
pg_catalog | pg_attribute | 472
public | quad_poly_tbl | 353
public | tenk2 | 349
public | tenk1 | 349
public | gin_test_idx | 306
pg_catalog | pg_largeobject | 206
public | gin_test_tbl | 188
public | spgist_text_tbl | 182
(10 rows)
regression=# SELECT * FROM pg_buffercache_summary();
buffers_used | buffers_unused | buffers_dirty | buffers_pinned | usagecount_avg
--------------+----------------+---------------+----------------+----------------
248 | 2096904 | 39 | 0 | 3.141129
(1 row)
regression=# SELECT * FROM pg_buffercache_usage_counts();
usage_count | buffers | dirty | pinned
-------------+---------+-------+--------
0 | 14650 | 0 | 0
1 | 1436 | 671 | 0
2 | 102 | 88 | 0
3 | 23 | 21 | 0
4 | 9 | 7 | 0
5 | 164 | 106 | 0
(6 rows)
</screen>
</sect2>
<sect2 id="pgbuffercache-authors">
<title>Authors</title>
<para>
Mark Kirkwood <email>markir@paradise.net.nz</email>
</para>
<para>
Design suggestions: Neil Conway <email>neilc@samurai.com</email>
</para>
<para>
Debugging advice: Tom Lane <email>tgl@sss.pgh.pa.us</email>
</para>
</sect2>
</sect1>