Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 803B1475AEC for ; Fri, 1 Nov 2002 18:03:57 -0500 (EST) Received: from absinthe.carnagecopia.com (absinthe.carnagecopia.com [216.187.87.246]) by postgresql.org (Postfix) with SMTP id 921DA474E44 for ; Fri, 1 Nov 2002 18:03:56 -0500 (EST) Received: (qmail 11601 invoked by uid 85); 1 Nov 2002 23:03:58 -0000 Received: from random@goblinstudios.com by absinthe.carnagecopia.com with qmail-scanner-1.03 (uvscan: v4.1.60/v4231. . Clean. Processed in 0.396622 secs); 01 Nov 2002 23:03:58 -0000 Received: from unknown (HELO workstation-22.internal.carnagecopia.com) (204.244.192.2) by absinthe.carnagecopia.com with SMTP; 1 Nov 2002 23:03:57 -0000 Date: Fri, 1 Nov 2002 18:03:57 -0500 From: Vincent Janelle To: "Gaetano Mendola" Cc: pgsql-admin@postgresql.org Subject: Re: Reindex vs Vacuum analyze Message-Id: <20021101180357.069fa8e0.random@goblinstudios.com> In-Reply-To: References: Organization: http://www.goblinstudios.com/ X-Mailer: Sylpheed version 0.8.5 (GTK+ 1.2.10; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/30 X-Sequence-Number: 6218 when entries are deleted from an table they're not deleted from the index, and vacuum doesn't clean them up. reindex recreates the index. It is suggested that you run a script at whatever necessary intervals to recreate the indexes on your tables if they have large amounts of data deleted from them on a regular basis. Mine creates a temporary index, drops the old index, and renames the temp index to the old one's name. After all that, then it performs a vacuum. On Fri, 1 Nov 2002 12:27:48 +0100 "Gaetano Mendola" wrote: > I repeat my simple experience for > know about what is going on: > > push=# explain analyze select * from jobs where status = 'r'; > NOTICE: QUERY PLAN: > > Index Scan using idx_jobs_status_r on jobs (cost=0.00..8.57 rows=3770 > width=49) > (actual time=19.26..1295.73 rows=5 loops=1) > Total runtime: 1295.85 msec > > EXPLAIN > push=# vacuum analyze jobs; > VACUUM > push=# explain analyze select * from jobs where status = 'r'; > NOTICE: QUERY PLAN: > > Index Scan using idx_jobs_status_r on jobs (cost=0.00..3.12 rows=1 > width=49) > (actual time=0.08..1318.36 rows=5 loops=1) > Total runtime: 1318.48 msec > > EXPLAIN > push=# reindex table jobs; > REINDEX > push=# explain analyze select * from jobs where status = 'r'; > NOTICE: QUERY PLAN: > > Index Scan using idx_jobs_status_r on jobs (cost=0.00..3.12 rows=1 > width=49) (actual time=0.04..0.15 rows=4 loops=1) > Total runtime: 0.24 msec