X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 3438CD1B475 for ; Tue, 2 Dec 2003 19:28:56 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 84577-01 for ; Tue, 2 Dec 2003 15:28:29 -0400 (AST) Received: from davinci.ethosmedia.com (server228.ethosmedia.com [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 35932D1B4B3 for ; Tue, 2 Dec 2003 15:28:24 -0400 (AST) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 4012391; Tue, 02 Dec 2003 11:29:18 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Jeremiah Jahn , postgres performance Subject: Re: cross table indexes or something? Date: Tue, 2 Dec 2003 11:27:52 -0800 User-Agent: KMail/1.4.3 References: <1069877651.22346.13.camel@bluejay.goodinassociates.com> <200312011147.51359.josh@agliodbs.com> <1070392092.22346.43.camel@bluejay.goodinassociates.com> In-Reply-To: <1070392092.22346.43.camel@bluejay.goodinassociates.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200312021127.52839.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200312/31 X-Sequence-Number: 4891 Jeremiah, > Thanks to all, I had already run analyze. But the STATISTICS setting > seems to have worked. I'm just not sure what it did..? Would anyone care > to explain. The STATISTICS setting improves the granularity of statistics kept by the query planner on that column; increasing the granularity (i.e. more random samples) can significantly improve things in cases where you have data whose distribution is significantly skewed. Certainly whenever you see the query planner using a slow nestloop becuase of a bad row-return estimate, it is one of the first things to try. Its drawbacks are 4-fold: 1) to keep it working, you will probably need to run ANALZYE more often than you have been; 2) these ANALYZEs will take longer, and have the annoying side effect of flooring your CPU while they do; 3) You will have to be sure that your vacuum plan includes vacuuming the pg_statistic table as the database superuser, as that table will be getting updated more often. 4) Currently, pg_dump does *not* back up statistics settings. So you will need to save a script which does this in preparation for having to restore your database. Which is why the stats are set low by default. -- Josh Berkus Aglio Database Solutions San Francisco