Re: How to terminate a query

From: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
To: A B <gentosaker(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How to terminate a query
Date: 2010-04-20 21:39:05
Message-ID: k2vdcc563d11004201439j2733c24bs55bf0ad019e4a44e@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Apr 20, 2010 at 2:42 PM, A B <gentosaker(at)gmail(dot)com> wrote:
> Hi there!
>
> select * from pg_stat_activity;
> shows me a
>  select my_function(....)
> query that has been running for too long.
> How do I kill it?

select pg_cancel_backend(pid);
will kill a running query.

> kill -9 of the procpid seems  to kill the entire server process. So

kill -9 is NOT recommended.

Sometimes cancel_backend fails because there's no point where the code
checks for a cancel.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andy 2010-04-20 21:48:54 Performance impact of log streaming replication
Previous Message Scott Marlowe 2010-04-20 21:37:04 Re: Can the log_statement parameter be set at the user level?