From jsomoza@pandasoftware.es Tue Feb 28 12:10:36 2006 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 9D2F29DCBF4 for ; Tue, 28 Feb 2006 08:10:36 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 89067-07 for ; Tue, 28 Feb 2006 08:10:39 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from bilbao.pandasoftware.es (unknown [62.14.249.71]) by postgresql.org (Postfix) with ESMTP id EE2FA9DCBDD for ; Tue, 28 Feb 2006 08:10:33 -0400 (AST) Received: from escorpexh05.pandasoftware.local (escorpext02 [192.168.100.182]) by bilbao.pandasoftware.es (Postfix) with ESMTP id D03D81B3748 for ; Tue, 28 Feb 2006 13:10:03 +0100 (CET) Received: from ESCORPEXH03.pandasoftware.local ([172.16.0.70]) by escorpexh05.pandasoftware.local with Microsoft SMTPSVC(6.0.3790.211); Tue, 28 Feb 2006 13:10:21 +0100 Received: escorpexh03.pandasoftware.local 172.16.0.73 from 172.16.3.16 172.16.3.16 via HTTP with MS-WebStorage 6.5.6944 Received: from pndsoft by escorpexh03.pandasoftware.local; 28 Feb 2006 13:11:05 +0100 Subject: vacuum, analyze and reindex From: Javier Somoza To: pgsql-performance@postgresql.org Content-Type: multipart/alternative; boundary="=-QO1J/z6tDBQ7dsbbZ1QI" Message-Id: <1141128665.1555.33.camel@pndsoft> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Tue, 28 Feb 2006 13:11:05 +0100 X-OriginalArrivalTime: 28 Feb 2006 12:10:21.0236 (UTC) FILETIME=[F25CB740:01C63C5F] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=1.134 required=5 tests=[AWL=1.132, HTML_MESSAGE=0.001, UNPARSEABLE_RELAY=0.001] X-Spam-Score: 1.134 X-Spam-Level: * X-Archive-Number: 200602/429 X-Sequence-Number: 17415 --=-QO1J/z6tDBQ7dsbbZ1QI Content-Type: text/plain Content-Transfer-Encoding: 7bit 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 --=-QO1J/z6tDBQ7dsbbZ1QI Content-Type: text/html; charset=utf-8

            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 --=-QO1J/z6tDBQ7dsbbZ1QI-- From cbbrowne@acm.org Tue Feb 28 13:38:10 2006 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id A1DFF9DCA3B for ; Tue, 28 Feb 2006 09:38:10 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 00508-07 for ; Tue, 28 Feb 2006 09:38:12 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) by postgresql.org (Postfix) with ESMTP id 738A99DC8A3 for ; Tue, 28 Feb 2006 09:38:06 -0400 (AST) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id 3847D30C22; Tue, 28 Feb 2006 14:38:10 +0100 (MET) From: Christopher Browne X-Newsgroups: pgsql.performance Subject: Re: vacuum, analyze and reindex Date: Tue, 28 Feb 2006 08:34:01 -0500 Organization: cbbrowne Computing Inc Lines: 41 Message-ID: <87mzgbsj3q.fsf@wolfe.cbbrowne.com> References: <1141128665.1555.33.camel@pndsoft> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@news.hub.org X-message-flag: Outlook is rather hackable, isn't it? X-Home-Page: http://www.cbbrowne.com/info/ X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne User-Agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4.19 (linux) Cancel-Lock: sha1:WQXF/N2TwnOziEX/N7aLpOxfL4Q= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.692 required=5 tests=[AWL=-0.121, INFO_TLD=0.813] X-Spam-Score: 0.692 X-Spam-Level: X-Archive-Number: 200602/430 X-Sequence-Number: 17416 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."