Re: select count(*) from pg_stat_activity in V8.0.0

From: "Anony Mous" <A(dot)Mous(at)shaw(dot)ca>
To: "'Richard Huxton'" <dev(at)archonet(dot)com>, "'Anony Mous'" <A(dot)Mous(at)shaw(dot)ca>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: select count(*) from pg_stat_activity in V8.0.0
Date: 2004-08-19 14:55:24
Message-ID: 005a01c485fc$8e9133f0$6902a8c0@PETER
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thanks, Richard.

I've never seen this behaviour before in 7.4.3 and indeed it is the only
connection to the back end at the time when the count is occurring. However,
it would have had the connection for at least 30 seconds before requesting a
count.

Is there a better method of obtaining the number of connections to the
backend?

Thanks
Peter

-----Original Message-----
From: Richard Huxton [mailto:dev(at)archonet(dot)com]
Sent: August 19, 2004 2:21 AM
To: Anony Mous
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: [GENERAL] select count(*) from pg_stat_activity in V8.0.0

Anony Mous wrote:
> Coming off of 7.4.3 I've always used
>
> select count(*) from pg_stat_activity
>
> through the ODBC driver to obtain the number of connections to the db.
I've
> found that with v8.0 Beta 1 that this at times has returned a value of 0
> (when there is obviously still a connection). It's not repeatable, and
> occurs sporadically. Does anyone have any reason as to why this would be
> isolated to V8? Is this an acceptable means of obtaining the number of
> connection to the database in V8 (via ODBC).

Do you have multiple live connections? My understanding of
pg_stat_activity is that it can lag slightly behind the current state of
the system. If the only connection that is active is the one doing the
counting you could be checking before the table has been updated.

--
Richard Huxton
Archonet Ltd

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Peter Eisentraut 2004-08-19 15:07:49 Re: Pass parameters to SQL script
Previous Message peter@remindex 2004-08-19 14:51:10 Re: select count(*) from pg_stat_activity in V8.0.0