display previous query string of idle-in-transaction - Mailing list pgsql-hackers

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
limit1;
 

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

Thoughts?

Best regards.

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


pgsql-hackers by date:

Previous
From: Guillaume Smet
Date:
Subject: Re: New trigger option of pg_standby
Next
From: Fujii Masao
Date:
Subject: Re: New trigger option of pg_standby