Re: [BUGS] LEFT JOINs not optimized away when not needed

From: David Fetter <david(at)fetter(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Cc: Moshe Jacobson <moshe(at)neadwerx(dot)com>, pgsql-bugs(at)postgresql(dot)org, Robert Mowlavi <robert(at)neadwerx(dot)com>, Chris Autry <chris(at)neadwerx(dot)com>
Subject: Re: [BUGS] LEFT JOINs not optimized away when not needed
Date: 2014-07-08 15:45:02
Message-ID: 20140708154502.GA6759@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On Tue, Jul 08, 2014 at 11:19:31AM -0400, Tom Lane wrote:
> Moshe Jacobson <moshe(at)neadwerx(dot)com> 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 <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david(dot)fetter(at)gmail(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Moshe Jacobson 2014-07-08 18:33:14 Re: LEFT JOINs not optimized away when not needed
Previous Message Tom Lane 2014-07-08 15:19:31 Re: LEFT JOINs not optimized away when not needed

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2014-07-08 15:45:37 Re: How to use Makefile - pgxs without gcc -O2 ?
Previous Message geohas 2014-07-08 15:28:01 How to use Makefile - pgxs without gcc -O2 ?