Skip site navigation (1) Skip section navigation (2)

Re: reading pg_stat_activity view

From: "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>
To: "Tena Sakai" <tsakai(at)gallo(dot)ucsf(dot)edu>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: reading pg_stat_activity view
Date: 2007-12-13 21:57:27
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-admin
On Dec 13, 2007 3:43 PM, Tena Sakai <tsakai(at)gallo(dot)ucsf(dot)edu> wrote:
>  My next question:
>  What would be a good way to tell if some
>  query is hung?

That would really depend on what you mean by hung.  Just running a
really long time, or waiting for a lock that some other session is not
will to commit / rollback like above?

I take it you just mean long running queries.  You can do a couple of
things.  You can set the value for statement_timeout and any statement
that takes over that amount of time will generate a timeout and you
then log it in the logs.

You can use pg_stat_activity to see how long a query's been running.
Something like

select datname, usename, current_query, waiting, now() - query_start
from pg_stat_activity order by query_start;

can show you how long each query has been running.

In response to


pgsql-admin by date

Next:From: Tena SakaiDate: 2007-12-13 22:39:18
Subject: Re: reading pg_stat_activity view
Previous:From: Andrew SullivanDate: 2007-12-13 21:49:47
Subject: Re: Dangerous hint in the PostgreSQL manual

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group