Re: Query gone wild

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Neil Conway <neilc(at)samurai(dot)com>
Cc: Garo Hussenjian <garo(at)xapnet(dot)com>, PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Query gone wild
Date: 2003-01-29 19:11:56
Message-ID: 28373.1043867516@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Neil Conway <neilc(at)samurai(dot)com> writes:
> On Wed, 2003-01-29 at 12:58, Garo Hussenjian wrote:
>> Is there any way to view the query
>> that is being run from knowing a process id?

> You can use the pg_stat_activity view in PostgreSQL 7.2 and later -- see

However, he probably doesn't have stats_command_string turned on, or
he'd already be aware of pg_stat_activity :-(. So this isn't much help
if the problem is to determine what an already-running query is.

Another possibility is to attach to the runaway process with a debugger
and print debug_query_string. For example, with gdb:

$ gdb /path/to/postgres-executable
gdb> attach PID-OF-PROCESS
gdb> p debug_query_string
gdb> quit

This should work unless you are running a stripped backend executable.
(On many systems, the "file" command can tell you whether an executable
has been stripped of debug symbols.)

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Justin Clift 2003-01-29 19:27:51 Re: Installing PG 7.3.1 on Solaris 8
Previous Message greg 2003-01-29 19:11:10 Re: Website troubles