Skip to content

Latest commit

 

History

History
47 lines (31 loc) · 1.09 KB

0074_how_to_flush_caches.md

File metadata and controls

47 lines (31 loc) · 1.09 KB

Originally from: tweet, LinkedIn post.


How to flush caches (OS page cache and Postgres buffer pool)

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.

Flushing Postgres buffer pool

To flush Postgres buffer pool, restart Postgres.

To analyze the current state of the buffer pool, use pg_buffercache.

Flushing OS page cache

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