How to identify long-running queries, not just long-running backends? - Mailing list pgsql-general

From Jeff Boes
Subject How to identify long-running queries, not just long-running backends?
Date
Msg-id d2h57f$2451$1@news.hub.org
Whole thread Raw
Responses Re: How to identify long-running queries, not just long-running backends?  (Jeff Boes <jboes@nexcerpt.com>)
List pgsql-general
I need a way to identify Pg backends which have been running a given
query for a long time. What I have so far is to use pg_stat_activity and
the process table (in my case, via Perl's Proc::ProcessTable) to
identify processes with a lot of CPU usage and an active query. The
problem is false positives: since we use a daemon architecture which may
keep a Pg backend open for a while and run many, many queries, I can't
tell the difference between a backend which has run one query with
elapsed time of several minutes, and a backend which has run 1000
queries each with a sub-second elapsed time.

What I'm really hoping for is a way to get the "start time" for a query
in pg_stat_activity.

I'm using 7.4.1, by the way.

--
Jeff Boes                                         Vox 269-226-9550 x24
Director of Software Development                  Fax 269-349-9076

Exfacto!         Exceptional Online Content     http://www.exfacto.com
Nexcerpt         ...Extend Your Expertise...    http://www.nexcerpt.com

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: truncate/create slowness
Next
From: Jeff Boes
Date:
Subject: Re: How to identify long-running queries, not just long-running backends?