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 9D55611F622C for ; Fri, 7 Apr 2006 00:17:21 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 44078-01 for ; Fri, 7 Apr 2006 00:17:19 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 97C7611F622A for ; Fri, 7 Apr 2006 00:17:18 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k373HGU4003545; Thu, 6 Apr 2006 23:17:17 -0400 (EDT) To: Brian Herlihy cc: pgsql-performance@postgresql.org Subject: Re: Query planner is using wrong index. In-reply-to: <20060406092711.8725.qmail@web52315.mail.yahoo.com> References: <20060406092711.8725.qmail@web52315.mail.yahoo.com> Comments: In-reply-to Brian Herlihy message dated "Thu, 06 Apr 2006 19:27:11 +1000" Date: Thu, 06 Apr 2006 23:17:16 -0400 Message-ID: <3544.1144379836@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.135 required=5 tests=[AWL=0.135] X-Spam-Score: 0.135 X-Spam-Level: X-Archive-Number: 200604/124 X-Sequence-Number: 18208 Brian Herlihy writes: > My options seem to be > - Fudge the analysis results so that the selectivity estimate changes. I > have tested reducing n_distinct, but this doesn't seem to help. > - Combine the columns into one column, allowing postgres to calculate the > combined selectivity. > - Drop the (p2, p3) index. But I need this for other queries. Have you considered reordering the pkey to be (p2,p3,p1) and then dropping the (p2,p3) index? regards, tom lane