Query to detect long-running transactions?

From: Brian Hurt <bhurt(at)janestcapital(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Query to detect long-running transactions?
Date: 2007-10-22 14:46:58
Message-ID: 471CB7E2.40602@janestcapital.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice


I'm wondering if there is a query I could run to detect long-running
transactions? Basically, I want to know all transactions (either on a
given server or just on a given database) that have been running for
longer than some parameterized amount of time.

I've spent some time with the friendly manual (especially Chapter 42 and
12), and didn't see anything usefull.

I'm having a problem with stupid humans (including yours truely)
forgetting they have a transaction outstanding and wandering off for a
weekend. What I'd like to do is write a quick script that queries the
database every so often, and if it finds a transaction that's been
running to long, send out an email warning people. I might be able to
do this by grovelling through the logs, although it'd be much easier to
do it with a query.

Thanks.

Brian

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message A. Kretschmer 2007-10-22 16:00:29 Re: Query to detect long-running transactions?
Previous Message Greg Sabino Mullane 2007-10-21 12:45:32 Re: Pattern matching