Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 88404632333 for ; Fri, 16 Apr 2010 11:20:02 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 95695-06 for ; Fri, 16 Apr 2010 14:19:41 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 1357763229D for ; Fri, 16 Apr 2010 11:19:50 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id o3GEJmrV008535; Fri, 16 Apr 2010 10:19:48 -0400 (EDT) To: =?KOI8-U?B?96bUwcymyiD0yc3eydvJzg==?= cc: pgsql-performance@postgresql.org Subject: Re: Planner not using column limit specified for one column for another column equal to first In-reply-to: References: Comments: In-reply-to =?KOI8-U?B?96bUwcymyiD0yc3eydvJzg==?= message dated "Fri, 16 Apr 2010 11:02:06 +0300" Date: Fri, 16 Apr 2010 10:19:47 -0400 Message-ID: <8534.1271427587@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.117 tagged_above=-10 required=5 tests=AWL=-0.207, BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201004/204 X-Sequence-Number: 38454 =?KOI8-U?B?96bUwcymyiD0yc3eydvJzg==?= writes: > I've thought and someone in this list've told me that this should be done > automatically. No, that's not true. We do make deductions about transitive equalities, ie, given WHERE a=b AND b=c the planner will infer a=c and use that if it's helpful. We don't make deductions about inequalities such as a>c. In theory there's enough information available to do so, but overall trying to do that would probably waste more cycles than it would save. You'd need a lot of expensive new planner infrastructure, and in the vast majority of queries it wouldn't produce anything very helpful. As was pointed out, even if we had such logic it wouldn't apply in this example, because the equality conditions aren't real equalities but OUTER JOIN conditions. regards, tom lane