pg_buffercache 延伸功能提供了一個即時檢查共享緩衝區配置情況的方法。
該模塊提供了一個 C 函數的 pg_buffercache_pages,該函數回傳一組記錄,以及一個檢視表 pg_buffercache,該檢視表封裝了該函數以便於使用。
預設情況下,僅限於超級使用者和 pg_monitor 角色的成員使用。也可以使用 GRANT 將存取權限授予其他角色。
pg_buffercache
ViewTable F.15 中列出了此檢視表的欄位定義。
pg_buffercache
ColumnsThere is one row for each buffer in the shared cache. Unused buffers are shown with all fields null except bufferid
. 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 in pg_class
for some rows, or that there could even be incorrect joins. If you are trying to join against pg_class
, it's a good idea to restrict the join to rows having reldatabase
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, accessing pg_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.
Mark Kirkwood <
markir@paradise.net.nz
>
Design suggestions: Neil Conway <
neilc@samurai.com
>
Debugging advice: Tom Lane <
tgl@sss.pgh.pa.us
>