Re: LEFT JOINs not optimized away when not needed
От | Moshe Jacobson |
---|---|
Тема | Re: LEFT JOINs not optimized away when not needed |
Дата | |
Msg-id | CAJ4CxL=vTAQ1dVYtAQoeS636qniO1mOy8E83Q4w7YzWuYyqtdg@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: LEFT JOINs not optimized away when not needed (Robert Haas <robertmhaas@gmail.com>) |
Ответы |
Re: LEFT JOINs not optimized away when not needed
|
Список | pgsql-bugs |
On Thu, Jul 10, 2014 at 11:06 AM, Robert Haas <robertmhaas@gmail.com> wrote= : > CREATE VIEW person_with_cars AS > SELECT p.id, p.full_name, p.something_else, array_agg(c.plate_number) > AS plate_numbers > FROM person p LEFT JOIN cars c ON p.id =3D c.person_id > GROUP BY p.id, p.full_name, p.something_else; > > 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. Moshe Jacobson Manager of Systems Engineering, Nead Werx Inc. <http://www.neadwerx.com> 2323 Cumberland Parkway =C2=B7 Suite 201 =C2=B7 Atlanta, GA 30339 "Quality is not an act, it is a habit." -- Aristotle
В списке pgsql-bugs по дате отправления: