In this recipe, we will be discussing how to clean the cache from databases at operating system level.
In PostgreSQL, we do not have any predefined functionality to clear the cache from the memory. To clear the database level cache, we need to shut down the whole instance and to clear the operating system cache, we need to use the operating system utility commands.
Do not run any of the following operations in any production servers as it will cause production outage.
benchmarksql=# SELECT pg_prewarm('bmsql_customer', 'buffer'); pg_prewarm ------------ 25211 (1 row)