mirror of
				https://github.com/postgres/postgres.git
				synced 2025-10-29 22:49:41 +03:00 
			
		
		
		
	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
		
			
				
	
	
		
			29 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			SQL
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			SQL
		
	
	
	
	
	
| CREATE EXTENSION pg_buffercache;
 | |
| 
 | |
| select count(*) = (select setting::bigint
 | |
|                    from pg_settings
 | |
|                    where name = 'shared_buffers')
 | |
| from pg_buffercache;
 | |
| 
 | |
| select buffers_used + buffers_unused > 0,
 | |
|         buffers_dirty <= buffers_used,
 | |
|         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();
 |