Following little script which utilizes linux-fincore hosted here gives you the OS disk cache resident pages of the tables in your pgbench database, the one used in a typical pgbench test.
echo “tablename | size | total_pages | min_cached page | cached_pages | cached_size | cached_perc”
psql -d pgbench -tc \
“SEELCT ‘$PGDATA/base/’ || d.oid::text || ‘/’ || c.relfilenode::text, c.relname\
FROM pg_class c, pg_database d\
WHERE c.relname LIKE ‘pgbench_%’ AND d.datname=’pgbench’” | \
tr -d ” ” | \
sed ‘s/|/\t/g’ |\
grep -v “^$” | \
while read path file; \
do \
echo -n $file;
linux-fincore -so $path | \
grep -v “filename\|—” |\
awk \
‘{print “\t”, $2,”\t”,$3,”\t”,$4,”\t”,$5,”\t”,$6,”\t”,$7}’ | \
tr -d “,”; \
done
