Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1X4XZv-0005H4-9a for pgsql-hackers@arkaria.postgresql.org; Tue, 08 Jul 2014 15:45:11 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1X4XZu-0004Oh-Pc for pgsql-hackers@arkaria.postgresql.org; Tue, 08 Jul 2014 15:45:10 +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 1X4XZt-0004OT-Fu; Tue, 08 Jul 2014 15:45:09 +0000 Received: from 173-164-140-181-sfba.hfc.comcastbusiness.net ([173.164.140.181] helo=fetter.org) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1X4XZp-0007Tj-4p; Tue, 08 Jul 2014 15:45:08 +0000 Received: by fetter.org (Postfix, from userid 500) id E79D66409B; Tue, 8 Jul 2014 08:45:02 -0700 (PDT) Date: Tue, 8 Jul 2014 08:45:02 -0700 From: David Fetter To: Tom Lane , PG Hackers Cc: Moshe Jacobson , pgsql-bugs@postgresql.org, Robert Mowlavi , Chris Autry Subject: Re: [BUGS] LEFT JOINs not optimized away when not needed Message-ID: <20140708154502.GA6759@fetter.org> References: <8401.1404832771@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8401.1404832771@sss.pgh.pa.us> User-Agent: Mutt/1.5.23 (2014-03-12) X-Pg-Spam-Score: -0.9 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On Tue, Jul 08, 2014 at 11:19:31AM -0400, Tom Lane wrote: > Moshe Jacobson writes: > > > Seeing that there is only one output column, and that the results are > > grouped by this output column, it seems to me that the optimizer should not > > even look at the rest of the tables. > > The GROUP BY has nothing to do with it, but if all the other tables' join > keys are primary keys (or at least unique), I'd expect the planner to get > rid of the joins. However, I'm not sure whether it works completely when > there are more than join_collapse_limit relations to worry about. Eliminating JOINs seems orthogonal, at least in theory, to join_collapse_limit. What have I missed here, and how might they have dependencies? Cheers, David. -- David Fetter http://fetter.org/ Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter Skype: davidfetter XMPP: david.fetter@gmail.com iCal: webcal://www.tripit.com/feed/ical/people/david74/tripit.ics Remember to vote! Consider donating to Postgres: http://www.postgresql.org/about/donate -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers