pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Markus Wollny <Markus.Wollny@computec.de>
To: Postgres <pgsql-admin@postgresql.org>
Subject: Re: Checking what is the current query running
Date: Tue, 25 Jul 2006 11:34:28 +0200
Message-ID: <28011CD60FB1724DBA4442E38277F62601C95103@hermes.computec.de> (raw)

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





view thread (6+ messages)  latest in thread

Message-ID: <28011CD60FB1724DBA4442E38277F62601C95103@hermes.computec.de>
Permalink:  ../28011CD60FB1724DBA4442E38277F62601C95103@hermes.computec.de/
Also on:    postgresql.org/message-id/28011CD60FB1724DBA4442E38277F62601C95103@hermes.computec.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: Markus.Wollny@computec.de
  Subject: Re: Checking what is the current query running
  In-Reply-To: <28011CD60FB1724DBA4442E38277F62601C95103@hermes.computec.de>
  References: <28011CD60FB1724DBA4442E38277F62601C95103@hermes.computec.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox