Movatterモバイル変換


[0]ホーム

URL:



Facebook
Postgres Pro
Facebook
Downloads
F.24. pg_buffercache
Prev UpAppendix F. Additional Supplied ModulesHome Next

F.24. pg_buffercache

Thepg_buffercache module provides a means for examining what's happening in the shared buffer cache in real time.

The module provides a C functionpg_buffercache_pages that returns a set of records, plus a viewpg_buffercache that wraps the function for convenient use.

By default, use is restricted to superusers and members of thepg_monitor role. Access may be granted to others usingGRANT.

F.24.1. Thepg_buffercache View

The definitions of the columns exposed by the view are shown inTable F.15.

Table F.15. pg_buffercache Columns

NameTypeReferencesDescription
bufferidinteger ID, in the range 1..shared_buffers
relfilenodeoidpg_class.relfilenodeFilenode number of the relation
reltablespaceoidpg_tablespace.oidTablespace OID of the relation
reldatabaseoidpg_database.oidDatabase OID of the relation
relforknumbersmallint Fork number within the relation; seeinclude/common/relpath.h
relblocknumberbigint Page number within the relation
isdirtyboolean Is the page dirty?
usagecountsmallint Clock-sweep access count
pinning_backendsinteger Number of backends pinning this buffer

There is one row for each buffer in the shared cache. Unused buffers are shown with all fields null exceptbufferid. Shared system catalogs are shown as belonging to database zero.

Because the cache is shared by all the databases, there will normally be pages from relations not belonging to the current database. This means that there may not be matching join rows inpg_class for some rows, or that there could even be incorrect joins. If you are trying to join againstpg_class, it's a good idea to restrict the join to rows havingreldatabase equal to the current database's OID or zero.

Since buffer manager locks are not taken to copy the buffer state data that the view will display, accessingpg_buffercache view has less impact on normal buffer activity but it doesn't provide a consistent set of results across all buffers. However, we ensure that the information of each buffer is self-consistent.

F.24.2. Sample Output

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)

F.24.3. Authors

Mark Kirkwood<markir@paradise.net.nz>

Design suggestions: Neil Conway<neilc@samurai.com>

Debugging advice: Tom Lane<tgl@sss.pgh.pa.us>


Prev Up Next
F.23. passwordcheck Home F.25. pgcrypto
epubpdf
Go to PostgreSQL 12
By continuing to browse this website, you agree to the use of cookies. Go toPrivacy Policy.

[8]ページ先頭

©2009-2025 Movatter.jp