mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Add pg_buffercache_usage_counts() to contrib/pg_buffercache.
It was pointed out that pg_buffercache_summary()'s report of the overall average usage count isn't that useful, and what would be more helpful in many cases is to report totals for each possible usage count. Add a new function to do it like that. Since pg_buffercache 1.4 is already new for v16, we don't need to create a new extension version; we'll just define this as part of 1.4. Nathan Bossart Discussion: https://postgr.es/m/20230130233040.GA2800702@nathanxps13
This commit is contained in:
@ -10,15 +10,19 @@ select buffers_used + buffers_unused > 0,
|
||||
buffers_pinned <= buffers_used
|
||||
from pg_buffercache_summary();
|
||||
|
||||
SELECT count(*) > 0 FROM pg_buffercache_usage_counts() WHERE buffers >= 0;
|
||||
|
||||
-- Check that the functions / views can't be accessed by default. To avoid
|
||||
-- having to create a dedicated user, use the pg_database_owner pseudo-role.
|
||||
SET ROLE pg_database_owner;
|
||||
SELECT * FROM pg_buffercache;
|
||||
SELECT * FROM pg_buffercache_pages() AS p (wrong int);
|
||||
SELECT * FROM pg_buffercache_summary();
|
||||
SELECT * FROM pg_buffercache_usage_counts();
|
||||
RESET role;
|
||||
|
||||
-- Check that pg_monitor is allowed to query view / function
|
||||
SET ROLE pg_monitor;
|
||||
SELECT count(*) > 0 FROM pg_buffercache;
|
||||
SELECT buffers_used + buffers_unused > 0 FROM pg_buffercache_summary();
|
||||
SELECT count(*) > 0 FROM pg_buffercache_usage_counts();
|
||||
|
Reference in New Issue
Block a user