Re: [HACKERS] Kill a Long Running Query

From: Heikki Linnakangas <heikki(at)enterprisedb(dot)com>
To: Mageshwaran <j_mageshwaran(at)sifycorp(dot)com>
Cc: pgsql-general(at)postgresql(dot)org, pgsql-admin(at)postgresql(dot)org, Postgres <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [HACKERS] Kill a Long Running Query
Date: 2007-04-25 14:56:50
Message-ID: 462F6C32.5010604@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-general pgsql-hackers

Please don't cross-post to multiple mailing lists. And pgsql-hackers is
not the correct list for basic usage questions. And long end-of-mail
disclaimers are not generally appreciated.

Mageshwaran wrote:
> Any body tell me how to kill a long running query in postgresql, is
> there any statement to kill a query,

See the user manual on administration functions, pg_cancel_backend in
particular:

http://www.postgresql.org/docs/8.2/interactive/functions-admin.html

Basically you issue a "SELECT * FROM pg_stat_activity", or plain ps to
find out the pid of the backend executing the long running query, and
then use pg_cancel_backend (or kill -INT) to cancel it.

> and also tell me how to log slow queries to a log file.

Using the log_min_duration_statement configuration variable.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Andrew Dunstan 2007-04-25 14:56:51 Re: [HACKERS] Kill a Long Running Query
Previous Message Aaron Bono 2007-04-25 14:53:50 Re: Kill a Long Running Query

Browse pgsql-general by date

  From Date Subject
Next Message Andrew Dunstan 2007-04-25 14:56:51 Re: [HACKERS] Kill a Long Running Query
Previous Message Richard Huxton 2007-04-25 14:56:45 Re: pg_connect sometimes works sometimes not

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2007-04-25 14:56:51 Re: [HACKERS] Kill a Long Running Query
Previous Message Aaron Bono 2007-04-25 14:53:50 Re: Kill a Long Running Query