How much of your pgbench test data is in the OS disk cache using linux-fincore

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

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s