PostgreSQL: Script to kill all idle sessions and connections of a Database

In this post, I am sharing one of the important script to kill all running idle connections and sessions of the PostgreSQL Database.

I have prepared this script such a way that you can also filter idle connections base on a particular time interval.

We are Database Administrator, and this is our responsibility to check idle connection periodically and if it requires to kill, we should do it.

To kill the connections is always not advisable, but in large systems where lots of transactions are going on in that situation we should kill idle connections base on a particular time interval.

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, 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.

More from

Leave a Reply

Be the First to Comment!

Notify of