Re: reading pg_stat_activity view

From: "Tena Sakai" <tsakai(at)gallo(dot)ucsf(dot)edu>
To: "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>
Cc: <pgsql-admin(at)postgresql(dot)org>
Subject: Re: reading pg_stat_activity view
Date: 2007-12-13 21:43:21
Message-ID: FE44E0D7EAD2ED4BB2165071DB8E328C03062E1A@egcrc-ex01.egcrc.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Hi Scott,

Thank you for an enlightening example! I see
it and I believe it.

My next question:
What would be a good way to tell if some
query is hung?

Regards,

Tena

-----Original Message-----
From: Scott Marlowe [mailto:scott(dot)marlowe(at)gmail(dot)com]
Sent: Thu 12/13/2007 11:47 AM
To: Tena Sakai
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: [ADMIN] reading pg_stat_activity view

On Dec 13, 2007 1:33 PM, Tena Sakai <tsakai(at)gallo(dot)ucsf(dot)edu> wrote:
>
> Hi everybody,
>
> As I look at output from pg_stat_activity view,
> I see often <idle> under query column and on the
> same row waiting column is always f. I gather
> that this is someone sitting at prompt of psql.
>
> My question: What does it mean when a query column
> lists a sql statment and waiting column f? Would
> this mean something is in a hung state?

Not what that means at all. :)

It means that the query is not waiting on locks from another query to
be released. Here's an example you can do yourself to see it happen:

T1: # create table test (a int, b text);
T1: # insert into test values (1,'abc');
T1: # insert into test values (2,'def');
T1: # begin;
T1: # select * from test where a=1 for update;
a | b
---+-----
1 | abc
(1 row)
T2: # update test set b='xyz' where a=1;
(T2 enters a wait state waiting on T1 to commit or rollback)

In another psql session, select * from pg_stat_activity where datname='mydb';
16385 | mydb | 13379 | 16384 | myname | update test set b='xyz'
where a=1; | t

Make sense?

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Andrew Sullivan 2007-12-13 21:49:47 Re: Dangerous hint in the PostgreSQL manual
Previous Message Tom Lane 2007-12-13 21:25:27 Re: Error Creating Tablespace