Re: pg_stat_activity xact_start and autovacuum

From: "Dawid Kuroczko" <qnex42(at)gmail(dot)com>
To: "Alvaro Herrera" <alvherre(at)commandprompt(dot)com>
Cc: "General postgres mailing list" <pgsql-general(at)postgresql(dot)org>
Subject: Re: pg_stat_activity xact_start and autovacuum
Date: 2008-02-11 13:56:52
Message-ID: 758d5e7f0802110556h75a6bc5fs69dde80b84d27f14@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Feb 11, 2008 2:27 PM, Alvaro Herrera <alvherre(at)commandprompt(dot)com> wrote:
> Dawid Kuroczko escribió:
> > I'm using 8.3.0 and I see that autovacuum processes in
> > pg_stat_activity have xact_start.
> >
> > As far as I know, since at least 8.2.x the VACUUM does not start a new
> > transaction.
> > If that statement is correct, the xact_start column in
> > pg_stat_activity should be NULL...
> > Why does it matter? Monitoring. It's good to know the age of oldest
> > running transaction, and autovacuuming is well, adding noise.
> Autovacuum certainly uses transactions ... ??

I am referrring to the E.8.3.5 Release 8.2 Release Notes:

* Allow VACUUM to expire rows without being affected by other
concurrent VACUUM operations (Hannu Krossing, Alvaro, Tom)

I have probably oversimplifed my statement above. What I am monitoring
is the age of the oldest transaction, to be alerted before tables accumulate
too many dead rows. From this point of view long running VACUUM is not
a problem (since relese 8.2).

Right now I am using:
SELECT extract('epoch' from min(xact_start)) AS oldest_xact_age
FROM pg_stat_activity
WHERE current_query NOT LIKE 'autovacuum:%';

...which works fine but somehow I feel that if xact_age would be NULL, it would
ring more true. Since VACUUM does not prevent VACUUMING it can take
days to complete and still I wouldn't need to worry. ;-)

Let me know if I mixed things up horribly. :-)

Regards,
Dawid

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2008-02-11 14:14:01 Re: pg_stat_activity xact_start and autovacuum
Previous Message Christopher Browne 2008-02-11 13:46:00 Re: end of life for pg versions...