Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id C8DA79FB638 for ; Wed, 18 Jul 2007 14:08:35 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 22628-03 for ; Wed, 18 Jul 2007 14:08:32 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.239]) by postgresql.org (Postfix) with ESMTP id EA53E9FB53B for ; Wed, 18 Jul 2007 14:08:31 -0300 (ADT) Received: by wx-out-0506.google.com with SMTP id h29so246217wxd for ; Wed, 18 Jul 2007 10:08:31 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type; b=M62Guqj6oTcD5GVUZqT5AySnhhU4zCNwOKpOpp9NoyB5VBLrvjygOkFYUrpKAheg3GHaEznzSzTCY7gkbwVW8ZoL6z3D9re6kiSwAzzO/E/SfbBpFNPpqaouoNNk//6iOJVRSx4Kakch7k85jN93AaWuzsiJJ/wCDFPXLyBp57s= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type; b=SXkgNUYsxevYxR4khun/R7OpYiFnMPicIVVV02Fj2TlGmjdjoS/ilN52JqLcczMxti472KXGcJeTMDZPU8YaGV/bq5aZ0OVYkNwgVOlR89pNn3GIe76/VK8uSaViruSF+0BvsDVcUROge+YPelTNjs9HEGfUKuTUUvY2THdAIug= Received: by 10.90.80.8 with SMTP id d8mr1801341agb.1184778511041; Wed, 18 Jul 2007 10:08:31 -0700 (PDT) Received: by 10.70.102.7 with HTTP; Wed, 18 Jul 2007 10:08:30 -0700 (PDT) Message-ID: <357fa7590707181008k65ab2f20l55bebb3c14f52770@mail.gmail.com> Date: Wed, 18 Jul 2007 13:08:30 -0400 From: "Steven Flatt" To: pgsql-performance@postgresql.org Subject: When/if to Reindex MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_90251_6347561.1184778510657" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200707/222 X-Sequence-Number: 25906 ------=_Part_90251_6347561.1184778510657 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline We're using Postgres 8.2.4. I'm trying to decide whether it's worthwhile to implement a process that does periodic reindexing. In a few ad hoc tests, where I've tried to set up data similar to how our application does it, I've noticed decent performance increases after doing a reindex as well as the planner being more likely to choose an index scan. Some background: we make extensive use of partitioned tables. In fact, I'm really only considering reindexing partitions that have "just closed". In our simplest/most general case, we have a table partitioned by a timestamp column, each partition 24 hours wide. The partition will have an index on the timestamp column as well as a few other indexes including a primary key index (all b-tree). Is there a programmatic way I can decide, upon the "closing" of a partition, which, if any, of these indexes will benefit from a reindex? Can I determine things like average node density, node depth, or any other indication as to the quality of an index? Will pg_class.relpages be any help here? Is it a simple matter of running some queries, reindexing the table, then running the queries again to determine overall performance change? If so, what queries would exercise this best? Just trying to determine if the extra cost of reindexing newly closed partitions will be worth the performance benefit of querying the data. Reindexing a table with a day's worth of data is taking on the order of a few hours (10s of millions of rows). The docs say that: "...for B-tree indexes a freshly-constructed index is somewhat faster to access than one that has been updated many times, because logically adjacent pages are usually also physically adjacent in a newly built index... It might be worthwhile to reindex periodically just to improve access speed." Thanks, Steve ------=_Part_90251_6347561.1184778510657 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline
We're using Postgres 8.2.4.
 
I'm trying to decide whether it's worthwhile to implement a process that does periodic reindexing.  In a few ad hoc tests, where I've tried to set up data similar to how our application does it, I've noticed decent performance increases after doing a reindex as well as the planner being more likely to choose an index scan.
 
Some background: we make extensive use of partitioned tables.  In fact, I'm really only considering reindexing partitions that have "just closed".  In our simplest/most general case, we have a table partitioned by a timestamp column, each partition 24 hours wide.  The partition will have an index on the timestamp column as well as a few other indexes including a primary key index (all b-tree).  Is there a programmatic way I can decide, upon the "closing" of a partition, which, if any, of these indexes will benefit from a reindex?  Can I determine things like average node density, node depth, or any other indication as to the quality of an index?  Will pg_class.relpages be any help here?
 
Is it a simple matter of running some queries, reindexing the table, then running the queries again to determine overall performance change?  If so, what queries would exercise this best?
 
Just trying to determine if the extra cost of reindexing newly closed partitions will be worth the performance benefit of querying the data.  Reindexing a table with a day's worth of data is taking on the order of a few hours (10s of millions of rows).
 
The docs say that:
 
"...for B-tree indexes a freshly-constructed index is somewhat faster to access than one that has been updated many times, because logically adjacent pages are usually also physically adjacent in a newly built index... It might be worthwhile to reindex periodically just to improve access speed."
 
Thanks,
Steve
 
------=_Part_90251_6347561.1184778510657--