Re: How to Kill IDLE users

Поиск
Список
Период
Сортировка
От Ang Chin Han
Тема Re: How to Kill IDLE users
Дата
Msg-id 8c8854360702272210v4f67d368tcd2de3a6f9943ecd@mail.gmail.com
обсуждение исходный текст
Ответ на Re: How to Kill IDLE users  (Scott Marlowe <smarlowe@g2switchworks.com>)
Список pgsql-general
On 2/28/07, Scott Marlowe <smarlowe@g2switchworks.com> 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.

В списке pgsql-general по дате отправления:

Предыдущее
От: "Jim C. Nasby"
Дата:
Сообщение: Re: Difference between UNIQUE constraint vs index
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Difference between UNIQUE constraint vs index