This article is half-done without your Comment! *** Please share your thoughts via Comment ***
This is one of the important discussion for PostgreSQL Database Administrator.
Yes, it is true that PostgreSQL has a caching system by setting “shared_buffers”.
But I didn’t find any perfect solution to clear the cache of PostgreSQL Server.
If you really want to clear cache, you should restart the PostgreSQL Server.
In this post, I provide you a short note on PostgreSQL Discard functionality to discard temp, query plan for running sessions.
Using DISCARD you can release internal resources of a Database Sessions.
DISCARD TEMP: Using this, you can drop all temporary tables which are created in the current session.
DISCARD PLANS: Using this, you can release all internal cached query plans.
DISCARD ALL: Using this, you can reset a session to its original state. You cannot execute this command inside the transaction block.
Once you have executed DISCARD ALL, internally following sequence executes.
SET SESSION AUTHORIZATION DEFAULT;