pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tatsuhito Kasahara <kasahara.tatsuhito@oss.ntt.co.jp>
To: pgsql-hackers@postgresql.org
Subject: display previous query string of idle-in-transaction
Date: Wed, 25 Mar 2009 18:08:43 +0900
Message-ID: <49C9F49B.8020003@oss.ntt.co.jp> (raw)

Hi.

Now, we can check the running query string by pg_stat_activity.current_query.
If we can also check previous query_string of idle-in-transaction,
it is useful for analysis of long transaction problem.

Long-transaction is a trouble, because it prevents defragmentation of HOT and VACUUM.
And long-transaction tends to be it in a state of "idle in transaction".
(BEGIN -> SOME SQL -> .... (long-transactin) ....)

So, I sometimes want to know what query (main cause) was done before
transaction which have been practiced for a long time.

I think that we are glad when we can confirm it in the following form.
# We will be able to use debug_query_string in postgres.c for this purpose.

=================================================================
=# SELECT current_query FROM pg_stat_activity
   WHERE procpid <> pg_backend_pid();

                         current_query
---------------------------------------------------------------
 <IDLE> in transaction [prev]: SELECT * FROM pg_class limit 1;

=================================================================

Thoughts?

Best regards.

-- 
Tatsuhito Kasahara
kasahara.tatsuhito@oss.ntt.co.jp



view thread (28+ messages)  latest in thread

Message-ID: <49C9F49B.8020003@oss.ntt.co.jp>
Permalink:  ../49C9F49B.8020003@oss.ntt.co.jp/
Also on:    postgresql.org/message-id/49C9F49B.8020003@oss.ntt.co.jp

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: kasahara.tatsuhito@oss.ntt.co.jp
  Subject: Re: display previous query string of idle-in-transaction
  In-Reply-To: <49C9F49B.8020003@oss.ntt.co.jp>

* 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