This article is half-done without your Comment! *** Please share your thoughts via Comment ***
In the previous post, I loaded table into the buffer cache of PostgreSQL (Using pg_prewarm).
PostgreSQL: Load table into Buffer Cache, Increase the Speed of Accessing data
In this post, I am sharing a script for checking the status of Shared buffer area of PostgreSQL.
Using pg_buffercache, we can check this. I took the script from the this official.
Please check the below script and output:
Create pg_buffercache module:
1 |
CREATE EXTENSION pg_buffercache; |
Script to check the status of Shared Buffer:
1 2 3 4 5 6 7 8 9 10 |
SELECT c.relname, count(*) AS buffers FROM pg_buffercache b INNER 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())) GROUP BY c.relname ORDER BY 2 DESC; |
Leave a Reply