Unix Technical Forum

vacuum, analyze and reindex

This is a discussion on vacuum, analyze and reindex within the Pgsql Performance forums, part of the PostgreSQL category; --> Hi all I've a question about vacuuming, ... Vacuum: cleans out obsolete and deleted registers... Analyze: update statistics for ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql Performance

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-19-2008, 08:12 AM
Javier Somoza
 
Posts: n/a
Default vacuum, analyze and reindex



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.


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?

Thx all

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-19-2008, 08:12 AM
Christopher Browne
 
Posts: n/a
Default Re: vacuum, analyze and reindex

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/>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 04:35 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com