As Scott mentioned, kill -9 on a Postgres process is not a wise idea on a Postgres process.

If you query is coming from another application, then terminating that application with a kill -9 *may* work, but is, as scott says, a last resort

I tend to use kill -TERM (15) to disconnect the client, which gives the log message " terminating connection due to administrator command"
kill -INT (2) gives the "cancelling statement due to user request" and does not disconnect the client.

So it depends on what you want to do.

If i have a runaway query (not so common on 9.1 now), Then i'll try the above, and if they don't work, then i'll try an /etc/init.d/postgresql stop or a pg_ctl stop -m f. then restart the server.

Only if that does not work will i consider killing using a -9.

Cheers

pgsql-general-owner@postgresql.org wrote on 19/07/2012 17:25:57:

> From: younus <younus.essahli@gmail.com>

> To: pgsql-general@postgresql.org,
> Date: 19/07/2012 20:30
> Subject: Re: [GENERAL] How to stop a query
> Sent by: pgsql-general-owner@postgresql.org
>
> Hi,
>
> Yes, I'm sure, it's work.
>
> if you execute query by another program (program java), you must use the
> first solution [ps -ef | grep postgres and  kill -9 (PID of your query)].
>
> if you use pgsql terminal and you're connecting with postgres you can use
> select procpid, datname, usename, client_addr,  current_query from
> pg_stat_activity where current_query!='<IDLE>';
> SELECT pg_cancel_backend (procpid);
>
>
>
>
> Younus.
>
> --
> View this message in context: http://postgresql.
> 1045698.n5.nabble.com/How-to-stop-a-query-tp1924086p5717297.html
> Sent from the PostgreSQL - general mailing list archive at Nabble.com.
>
> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>
============================================= Romax Technology Limited Rutherford House Nottingham Science & Technology Park Nottingham, NG7 2PZ England Telephone numbers: +44 (0)115 951 88 00 (main) For other office locations see: http://www.romaxtech.com/Contact ================================= =============== E-mail: info@romaxtech.com Website: www.romaxtech.com ================================= ================ Confidentiality Statement This transmission is for the addressee only and contains information that is confidential and privileged. Unless you are the named addressee, or authorised to receive it on behalf of the addressee you may not copy or use it, or disclose it to anyone else. If you have received this transmission in error please delete from your system and contact the sender. Thank you for your cooperation. =================================================