PostgreSQL does not have a built-in method to clear the buffer cache like Oracle does, so the only option is to clear the OS-level filesystem cache. Therefore, the title “clearing the buffer cache in PostgreSQL” is not quite accurate — what this actually does is clear the OS-level cache.
pg_ctl stop
sudo su - -c "echo 3 > /proc/sys/vm/drop_caches"
pg_ctl start
Reference
[pgsql-jp: 40643] Re: Question about how to clear PostgreSQL cache https://ml.postgresql.jp/pipermail/pgsql-jp/2010-December/015599.html