X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3526752828 for ; Mon, 27 Jun 2005 19:35:42 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 23107-05 for ; Mon, 27 Jun 2005 22:35:33 +0000 (GMT) Received: from davinci.ethosmedia.com (server227.ethosmedia.com [209.128.84.227]) by svr1.postgresql.org (Postfix) with ESMTP id 3CE9D52822 for ; Mon, 27 Jun 2005 19:35:32 -0300 (ADT) X-EthosMedia-Virus-Scanned: no infections found Received: from [64.81.245.111] (account josh@agliodbs.com HELO temoku.sf.agliodbs.com) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 7539091; Mon, 27 Jun 2005 15:37:42 -0700 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "Karl O. Pinc" Subject: Re: Poor index choice -- multiple indexes of the same columns Date: Mon, 27 Jun 2005 15:37:41 -0700 User-Agent: KMail/1.8 Cc: pgsql-performance@postgresql.org References: <1119913766l.4428l.2l@mofo> In-Reply-To: <1119913766l.4428l.2l@mofo> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200506271537.41797.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.045 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200506/506 X-Sequence-Number: 13143 Karl, > Seems to me that when there's a constant value in the query > and an = comparision it will always be faster to use the (b-tree) > index that's ordered first by the constant value, as then all further > blocks are guarenteed to have a higher relevant information > density. At least when compared with another index that has the > same columns in it. That really depends on the stats. Such a choice would *not* be appropriate if the < comparison was expected to return 1- rows while the = condition applied to 15% of the table. What is your STATISTICS_TARGET for the relevant columns set to? When's the last time you ran analyze? If this is all updated, you want to post the pg_stats rows for the relevant columns? -- --Josh Josh Berkus Aglio Database Solutions San Francisco