From: Christopher Browne <cbbrowne@acm.org>
To: pgsql-performance@postgresql.org
Subject: Re: vacuum, analyze and reindex
Date: Tue, 28 Feb 2006 08:34:01 -0500
Message-ID: <87mzgbsj3q.fsf@wolfe.cbbrowne.com> (raw)
References: <1141128665.1555.33.camel@pndsoft>
Centuries ago, Nostradamus foresaw when jsomoza@pandasoftware.es (Javier Somoza) would write:
> Hi all
> I've a question about vacuuming, ...
> Vacuum: cleans out obsolete and deleted registers...
> Analyze: update statistics for the planner
> Reindex: rebuild indexes
> I think the correct order to perform the database maintenance for performance is:
> 1 - Vacuum
> 2 - Reindex
> 3 - Analyze
> So the planner is updated with the updated indexes.
There is a misunderstanding there. The planner isn't aware of
"updates" to the indexes; it is aware of how they are defined.
ANALYZE doesn't calculate index-specific things; it calculates
statistical distributions for the contents of each column. As soon as
it runs, the planner will be better able to choose from the available
indexes. If you add another index, the planner will, without another
ANALYZE, be able to choose that index, if it is useful to do so, based
on the existing statistical distributions.
> The autovacuum daemon does vacuum and analyze. Not reindex.
> So, no way to perform it in that order.
> What do you think?
> How often do you reindex your tables?
If tables are being vacuumed frequently enough, the answer to that can
be "almost never."
Back in the days of 7.2, there were conditions where indexes could
bloat mercilessly, so that heavily updated tables needed a reindex
every so often. But if you're running a reasonably modern version,
that shouldn't be necessary.
--
wm(X,Y):-write(X),write('@'),write(Y). wm('cbbrowne','gmail.com').
http://linuxfinances.info/info/slony.html
Rules of the Evil Overlord #219. "I will be selective in the hiring of
assassins. Anyone who attempts to strike down the hero the first
instant his back is turned will not even be considered for the job."
<http://www.eviloverlord.com/;
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: cbbrowne@acm.org
Subject: Re: vacuum, analyze and reindex
In-Reply-To: <87mzgbsj3q.fsf@wolfe.cbbrowne.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox