Skip site navigation (1) Skip section navigation (2)

Re: Checking what is the current query running

From: "Markus Wollny" <Markus(dot)Wollny(at)computec(dot)de>
To: "Postgres" <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Checking what is the current query running
Date: 2006-07-25 09:34:28
Message-ID: 28011CD60FB1724DBA4442E38277F62601C95103@hermes.computec.de (view raw or flat)
Thread:
Lists: pgsql-admin
Hi,

pg_stat_activity has some limitations however; if you use a lot of
dynamically generated complex queries, you might stumble over the 255
character limit of current_query in pg_stat_activity, statement-strings
longer than that are just cut off.

You can get some more information if you need it, using the GNU debugger
gdb: First you need to determine the PID of the PostgreSQL backend
that's running your query - I usually use top for that, but
pg_stat_activity does also give you that info (select procpid from
pg_stat_activity ...). Once you have the PID, you start the GNU debugger
with

gdb [path_to_postgres] [pid]
e.g. gdb /opt/pgsql/bin/postgres 551

Now issue the command 
	printf "%s\n", debug_query_string
to obtain the query string. To quit the debugger, just type "quit" and
confirm - the backend will keep processing the query uninterrupted.

Kind regards

   Markus



Responses

pgsql-admin by date

Next:From: DilipkumarDate: 2006-07-25 10:15:31
Subject: Re: Checking what is the current query running
Previous:From: Shoaib MirDate: 2006-07-25 08:56:16
Subject: Re: Checking what is the current query running

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group