pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: daveg <daveg@sonic.net>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Tatsuhito Kasahara <kasahara.tatsuhito@oss.ntt.co.jp>
Cc: Kevin Grittner <Kevin.Grittner@wicourts.gov>
Cc: Greg Stark <stark@enterprisedb.com>
Cc: Asko Oja <ascoja@gmail.com>
Cc: Simon Riggs <simon@2ndquadrant.com>
Cc: decibel <decibel@decibel.org>
Cc: pgsql-hackers@postgresql.org
Subject: Re: display previous query string of idle-in-transaction
Date: Thu, 23 Jul 2009 22:28:10 -0700
Message-ID: <20090724052810.GF18614@sonic.net> (raw)
In-Reply-To: <603c8f070906041922u7eaf0f76l8c2b7cbd3049c69b@mail.gmail.com>
References: <49C9F49B.8020003@oss.ntt.co.jp>
	<1238091273.16568.530.camel@ebony.2ndQuadrant>
	<49CC75E3.7010101@oss.ntt.co.jp>
	<1238139418.16568.555.camel@ebony.2ndQuadrant>
	<A90F3088-EC12-4802-BFC0-BE7BFEBA08F9@decibel.org>
	<ecd779860905122156o48b3d07al75d2d21751c2a5bd@mail.gmail.com>
	<4136ffa0906030724g72a56165s33819f3060002dcb@mail.gmail.com>
	<4A264377.EE98.0025.1@wicourts.gov>
	<4A287AF3.9000301@oss.ntt.co.jp>
	<603c8f070906041922u7eaf0f76l8c2b7cbd3049c69b@mail.gmail.com>

On Thu, Jun 04, 2009 at 10:22:41PM -0400, Robert Haas wrote:
> The only thing I don't like about this is that I think it's kind of a
> hack to shove the <IDLE> in transaction designation and the query
> string into the same database column.  I've never liked having to
> write:
> 
> select sum(1) from pg_stat_activity where current_query = '<IDLE> in
> transaction';
> 
> ...and I like it even less if I now have to modify that query to use
> "like".  We should find some way to represent this as structured
> data...  maybe make a separate column called "idle" that's a boolean,
> or something, and let the query column contain the most recent query
> (whether or not it's still executing).
 
I like this idea a lot. Possibly it would be useful to have the end time
of the last query too, then one could find idle sessions that were old and
truly idle rather than just waiting for a busy client to send the next query.

   select ... from pg_stat_activity
     where idle
       and last_statement_endtime < now() - interval '1 minute';

-dg

-- 
David Gould       daveg@sonic.net      510 536 1443    510 282 0869
If simplicity worked, the world would be overrun with insects.



view thread (28+ messages)  latest in thread

Message-ID: <20090724052810.GF18614@sonic.net>
Permalink:  ../20090724052810.GF18614@sonic.net/
Also on:    postgresql.org/message-id/20090724052810.GF18614@sonic.net

 · 

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: daveg@sonic.net, robertmhaas@gmail.com, kasahara.tatsuhito@oss.ntt.co.jp, Kevin.Grittner@wicourts.gov, stark@enterprisedb.com, ascoja@gmail.com, simon@2ndquadrant.com, decibel@decibel.org
  Subject: Re: display previous query string of idle-in-transaction
  In-Reply-To: <20090724052810.GF18614@sonic.net>

* 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