Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1X4cBu-00066h-GK for pgsql-bugs@arkaria.postgresql.org; Tue, 08 Jul 2014 20:40:42 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1X4cBt-0002uL-T7 for pgsql-bugs@arkaria.postgresql.org; Tue, 08 Jul 2014 20:40:41 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1X4cBr-0002uB-VL for pgsql-bugs@postgresql.org; Tue, 08 Jul 2014 20:40:40 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1X4cBj-0004gn-A5 for pgsql-bugs@postgresql.org; Tue, 08 Jul 2014 20:40:39 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id s68KeSRn000710; Tue, 8 Jul 2014 16:40:28 -0400 From: Tom Lane To: Moshe Jacobson cc: pgsql-bugs@postgresql.org, Robert Mowlavi , Chris Autry Subject: Re: LEFT JOINs not optimized away when not needed In-reply-to: References: <8401.1404832771@sss.pgh.pa.us> <30516.1404848833@sss.pgh.pa.us> Comments: In-reply-to Moshe Jacobson message dated "Tue, 08 Jul 2014 15:57:21 -0400" Date: Tue, 08 Jul 2014 16:40:28 -0400 Message-ID: <709.1404852028@sss.pgh.pa.us> X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Moshe Jacobson writes: > On Tue, Jul 8, 2014 at 3:47 PM, Tom Lane wrote: >> AFAICS, the eight >> un-removed joins are either joining to non-unique keys, or can't be >> removed because their tables are needed to provide joining columns for >> un-removable joins. > My point is that even if the column to which we are joining is a non-unique > key, there should be no need to look at that table if the output does not > include any values from that table, and there are no filters on that > table's values, and all output columns are in the GROUP BY. Is the planner > not smart enough to notice this? No. There is nothing about GROUP BY in the join removal logic. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs