Re: View pg_stat_activity slow to get up to date

From: "D'Arcy J(dot)M(dot) Cain" <darcy(at)druid(dot)net>
To: Jan Wieck <JanWieck(at)Yahoo(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: View pg_stat_activity slow to get up to date
Date: 2004-11-08 18:06:47
Message-ID: 20041108130647.6f3621f0.darcy@druid.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 08 Nov 2004 12:56:57 -0500
Jan Wieck <JanWieck(at)Yahoo(dot)com> wrote:

Hi Jan.

> On 11/8/2004 12:03 PM, D'Arcy J.M. Cain wrote:
>
> > I checked the FAQ and docs but haven't found anything definitive.
> > This is my SQL test script:
> >
> > SELECT pg_backend_pid();
> > SELECT * FROM pg_stat_activity order by procpid;
> >
> > When I run psql reading that I find that my backend procpid is not
> > in the list. I know that I can see it if I can introduce a little
> > sleep (1 second) between the connection and the reading of
> > pg_stat_activity.
>
> That is because the way your backend gets the information from the
> pgstat daemon process is by reading a file, which is at maximum
> written by that process every 500 msec. You will hardly ever see your
> own query.

OK, I thought that using stats might not be the most reliable method but
I couldn't find any other. Is there a reliable way to get that info?
Note that I don't care what the backend is doing, just whether it is
still running or not.

> All these statistics are unreliable "by design", as explained numerous
>
> times on this list. In short, a backend should never be slowed down
> because the pgstat process can't swallow the stats fast enough. That
> is the reason for using UDP in the first place. So the kernel is
> allowed to drop stats packets, but not to block a backend.

So it is worse than I thought. I thought that it was slow but it looks
like it may never even make it. Probably OK for my purposes but it
would be nice to have a reliable method.

--
D'Arcy J.M. Cain <darcy(at)druid(dot)net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2004-11-08 18:07:34 Re: View pg_stat_activity slow to get up to date
Previous Message Tom Lane 2004-11-08 18:05:03 Re: [pgsql-www] pg_autovacuum is nice ... but ...