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;
Please share your ideas and opinions about this topic with me, your contribution will add true value to this topic.
If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.
If you like this post, then please share it with others.
Please follow dbrnd.com, I will share my experience towards the success of Database Research and Development Activity.
I put up a post every day, please keep reading and learning.
Discover Yourself, Happy Blogging !
Anvesh M. Patel.