Re: select count(*) from pg_stat_activity in V8.0.0 - Mailing list pgsql-general

From Richard Huxton
Subject Re: select count(*) from pg_stat_activity in V8.0.0
Date
Msg-id 4124EC03.2090106@archonet.com
Whole thread Raw
In response to Re: select count(*) from pg_stat_activity in V8.0.0  ("Anony Mous" <A.Mous@shaw.ca>)
List pgsql-general
Anony Mous wrote:
> 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?

Other than "ps" - no I don't think so. The 30 seconds doesn't sound
right, Tom reckoned 0.5sec which sounds plausible. Might this be the
first query you've sent on this connection?

I'm wondering if the ODBC connection isn't actually established until
you run the first query? It doesn't sound right to me, but I don't have
any of my ODBC apps to hand at the moment to check.

Could you:
1. Connect
2. SELECT 1; (or similar)
3. Sleep from 10msec => 1sec
4. SELECT * FROM pg_stat_activity;

That way we could disable step 2 and tinker with the delay in step 3 to
see what happens.

--
   Richard Huxton
   Archonet Ltd

pgsql-general by date:

Previous
From: Gaetano Mendola
Date:
Subject: Re: Finally tsearch works ... somehow... remain a few
Next
From: Shelby Cain
Date:
Subject: Re: Postgresql 8.0 beta 1 - strange cpu usage statistics and slow vacuuming