Search Postgresql Archives

Re: How to Kill IDLE users

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2/28/07, Scott Marlowe <smarlowe@xxxxxxxxxxxxxxxxx> wrote:

select procpid, usename, now()-query_start from pg_stat_activity where
current_query like '%IDLE%' and now()-query_start >  interval '5
minutes';

to list all the users that have been idle over the interval in the
list.  Using some kind of scripting language, you could then issue kill
signals to those procpids.

There's always pg_cancel_backend().
http://www.postgresql.org/docs/8.2/static/functions-admin.html

So:

select pg_cancel_backend(procpid) from pg_stat_activity where
current_query = '<IDLE>' and now() - query_start > interval '5
minutes';

should work nicely. I've not really tested that properly though.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux