Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VWMTR-0007dR-3j for pgsql-performance@arkaria.postgresql.org; Wed, 16 Oct 2013 08:28:57 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VWMTQ-0006rs-Ab for pgsql-performance@arkaria.postgresql.org; Wed, 16 Oct 2013 08:28:56 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VWMTP-0006rl-93 for pgsql-performance@postgresql.org; Wed, 16 Oct 2013 08:28:55 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VWMTI-0001KG-VF for pgsql-performance@postgresql.org; Wed, 16 Oct 2013 08:28:54 +0000 Received: from pro.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id r9G8SiDX014144; Wed, 16 Oct 2013 04:28:45 -0400 From: Tom Lane To: Gavin Wahl cc: pgsql-performance@postgresql.org Subject: Re: Planner Conceptual Error when Joining a Subquery -- Outer Query Condition not Pulled Into Subquery In-reply-to: References: Comments: In-reply-to Gavin Wahl message dated "Wed, 16 Oct 2013 00:33:56 -0600" Date: Wed, 16 Oct 2013 10:28:44 +0200 Message-ID: <7176.1381912124@sss.pgh.pa.us> X-Pg-Spam-Score: -2.4 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org Gavin Wahl writes: > It'd be nice if the planner could optimize the query (1) by turning it > into (2). I understand that it might not be able to, but if it can pull > the condition up in (3), why can't it in (4)? (3) is an instance of seeing "a = b and b = c" and deducing "a = c" from that. (4) does not follow that pattern, so it's outside the realm of what the planner can deduce. In principle we could take "a = b and (b = c or b = d)" and deduce "a = c or a = d" from that, but it'd be a lot more complication for a lot less benefit than what we get from the existing logic. regards, tom lane -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance