This article is half-done without your Comment! *** Please share your thoughts via Comment ***
This is one of the important topics for PostgreSQL Database Administrator.
Yes, it is true that PostgreSQL has a caching system.
But I didn’t find any perfect solution for clearing the cache of PostgreSQL Server.
If you want to clear cache, you should restart the PostgreSQL Server.
In this post, I am sharing a short note on PostgreSQL Discard functionality to discard temp, the query plan for running sessions.
Using DISCARD, you can release internal resources of the 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 runs.
SET SESSION AUTHORIZATION DEFAULT;