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
Views: Raw Message | Whole Thread | Download mbox | Resend email
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

Browse pgsql-admin by date

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