Generate a server activity report

To generate a server activity report, you can use the PostgreSQL cumulative statistics system to collect and report information about server activity. The server activity information is exposed as system tables, which can be accessed using SQL queries.

For example, the query reports the number of disk blocks found in the buffer cache and number of disk blocks read from disk:

SELECT blks_hit, blks_read FROM pg_stat_database;

By observing the values of these counters over time, you can infer whether the database is making good use of the buffer cache.

The PostgreSQL documentation has more information about this cumulative statistics system.