Re: LEFT JOINs not optimized away when not needed

From: Moshe Jacobson <moshe(at)neadwerx(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Postgres-Bugs <pgsql-bugs(at)postgresql(dot)org>, Robert Mowlavi <robert(at)neadwerx(dot)com>, Chris Autry <chris(at)neadwerx(dot)com>
Subject: Re: LEFT JOINs not optimized away when not needed
Date: 2014-07-10 20:18:27
Message-ID: CAJ4CxLkWyRASRNOZLcsgKP=aZ+T7xsaZ-MnWBfD9Zzh_YThs4w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On Thu, Jul 10, 2014 at 12:12 PM, Moshe Jacobson <moshe(at)neadwerx(dot)com> wrote:

> It's reasonable to hope that if the aggregated column isn't selected,
>> the join will get removed, but cars (person_id) is not unique.
>>
>
> Exactly. But the same should be true even if c.plate_number is not
> aggregated in the view def.
> As long as it's not selected, the output should list one row per person_id
> and the cars table should be removed from the join.
> What I've just described is our most common use case.
>

Oops, what I said may not have been clear.
The view def wouldn't have a GROUP BY in most of our use cases.
The GROUP BY would actually be used to group all of the columns selected
from the view.

Moshe Jacobson
Manager of Systems Engineering, Nead Werx Inc. <http://www.neadwerx.com>
2323 Cumberland Parkway · Suite 201 · Atlanta, GA 30339

"Quality is not an act, it is a habit." -- Aristotle

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message anuno1 2014-07-10 23:46:44 BUG #10919: Fix for BUG #9110: Fresh install of psqlodbc_09_03_0100-x64.zip fails
Previous Message Tom Lane 2014-07-10 19:41:41 Re: Compile fails on AIX 6.1

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2014-07-10 20:33:40 Re: Pg_upgrade and toast tables bug discovered
Previous Message Jeff Janes 2014-07-10 19:58:00 Re: TODO : Allow parallel cores to be used by vacuumdb [ WIP ]