Re: detection of VACUUM in progress

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Bohdan Linda <bohdan(dot)linda(at)seznam(dot)cz>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: detection of VACUUM in progress
Date: 2005-08-30 16:07:24
Message-ID: 20050830160724.GA57137@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Aug 30, 2005 at 05:35:13PM +0200, Bohdan Linda wrote:
>
> Is there any way how to detect running command VACUUM by reading pg_* tables?

If you have stats_command_string enabled then you could query
pg_stat_activity, but be aware that the results will be stale by
the time you see them (there's a slight lag in updating the stats
tables, and a VACUUM might start or complete immediately after you
issue the query but before you read the results). This method is
therefore unreliable.

> The idea is to detectect when table is not accessible due maintainance.

In modern versions of PostgreSQL a plain VACUUM (without FULL)
should have little impact on a table's accessibility unless you're
doing something that needs a strong lock (DDL, etc.). But VACUUM
FULL and a few other commands do prevent other transactions from
accessing a table, so if you want to check for accessibility then
you need to check for more than just VACUUM. You might be able to
use statement_timeout to make statements fail if they take longer
than expected, and infer from the failure that the table is
unavailable. But again, that information could be stale by the
time you see it -- the table might become available immediately
after you decide that it isn't.

What problem are you trying to solve? If we knew what you're really
trying to do then we might be able to make suggestions.

--
Michael Fuhr

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Clodoaldo Pinto 2005-08-30 16:07:26 Re: update functions locking tables
Previous Message Clodoaldo Pinto 2005-08-30 16:00:18 Re: update functions locking tables