Killing a session

Started by Vitaly Belmanover 21 years ago4 messagesgeneral
Jump to latest
#1Vitaly Belman
vitalyb@gmail.com

Is there a way to kill a session in PostrgeSQL? I ran a bad query by
mistake and I don't want to shut the whole database just to quit using
the whole CPU.

--
ICQ: 1912453
AIM: VitalyB1984
MSN: tmdagent@hotmail.com
Yahoo!: VitalyBe

#2Gregory S. Williamson
gsw@globexplorer.com
In reply to: Vitaly Belman (#1)
Re: Killing a session

kill -15 pid#

will kill a given thread ... you can look in the pg_stat_activity; the query_start shows when it started, the current_query shows at least a portion of the SQL the thread is executing, and procpid if the pid of the process to kill with a -15 command.

Not sure about Windows variants, though.

HTH

Greg Williamson
DBA
GlobeXplorer LLC

-----Original Message-----
From: Vitaly Belman [mailto:vitalyb@gmail.com]
Sent: Sat 8/21/2004 1:32 PM
To: pgsql-general@postgresql.org
Cc:
Subject: [GENERAL] Killing a session
Is there a way to kill a session in PostrgeSQL? I ran a bad query by
mistake and I don't want to shut the whole database just to quit using
the whole CPU.

--
ICQ: 1912453
AIM: VitalyB1984
MSN: tmdagent@hotmail.com
Yahoo!: VitalyBe

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Vitaly Belman (#1)
Re: Killing a session

Vitaly Belman <vitalyb@gmail.com> writes:

Is there a way to kill a session in PostrgeSQL? I ran a bad query by
mistake and I don't want to shut the whole database just to quit using
the whole CPU.

ISTM what you really want is query cancel, not whole-session kill.
Try "kill -INT <pid-of-backend>".

regards, tom lane

#4Vitaly Belman
vitalyb@gmail.com
In reply to: Vitaly Belman (#1)
Re: Killing a session

Even better. Thanks =).

On Sat, 21 Aug 2004 20:14:53 -0400, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Vitaly Belman <vitalyb@gmail.com> writes:

Is there a way to kill a session in PostrgeSQL? I ran a bad query by
mistake and I don't want to shut the whole database just to quit using
the whole CPU.

ISTM what you really want is query cancel, not whole-session kill.
Try "kill -INT <pid-of-backend>".

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

--
ICQ: 1912453
AIM: VitalyB1984
MSN: tmdagent@hotmail.com
Yahoo!: VitalyBe