Search code examples
postgresqlpostgresql-11

PostgreSQL - How to check the usage of shared_buffers


I am new to PostgreSQL and I would like to understand how can I see the utilization of shared_buffers in my PostgreSQL instance.

Let's assume I have shared_buffers = 8GB in my configuration, is there a way to check how much is being used in that 8GB?

Many Thanks, Suresh.


Solution

  • Use the pg_buffercache extension:

    CREATE EXTENSION pg_buffercache;
    

    That provides a view of the same name that shows exactly what is stored where.

    You can find empty buffers by looking for entries with usagecount IS NULL, but unless the server is newly started or the database is smaller than shared_buffers, you probably won't find any.