Calculate the database cache hit ratio:
14 Nov 2015
select sum(blks_hit) * 100 / sum(blks_hit + blks_read) as hit_ratio from pg_stat_database;
A newer way (11 Aug 2020):
select sum(heap_blks_read) as heap_read, sum(heap_blks_hit) as heap_hit, sum(heap_blks_hit) / (sum(heap_blks_hit) + sum(heap_blks_read)) as hit_ratio from pg_statio_user_tables;