Originally from: tweet, LinkedIn post.
I post a new PostgreSQL "howto" article every day. Join me in this journey – subscribe, provide feedback, share!
For experiments, it is important to take into account the state of caches – Postgres buffer pool (size of which is
controlled by shared_buffers
) and OS page cache. If we decide to start each experiment run with cold caches, we need
to flush them.
To flush Postgres buffer pool, restart Postgres.
To analyze the current state of the buffer pool, use pg_buffercache.
To flush Linux page cache:
sync
echo 3 > /proc/sys/vm/drop_caches
To see the current state of RAM consumption (in MiB) in Linux:
free -m
On macOS, to flush the page cache:
sync
sudo purge
To see the current state of RAM on macOS:
vm_stat