Thursday, December 13, 2012

PostgreSQL - Kill idle processes

Sometimes, you need to kill all unnecessary processes running on your database server. You can do that by using the following query:

SELECT           
   procpid,
   (
       SELECT pg_terminate_backend(procpid)
   ) AS killed
 FROM pg_stat_activity
 WHERE current_query LIKE '%idle%' AND datname = 'YourDBName';

No comments:

Post a Comment

Oracle Query