Re: unneeded joins on view

From: Linos <info(at)linos(dot)es>
To: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>, pgsql-performance(at)postgresql(dot)org
Subject: Re: unneeded joins on view
Date: 2014-04-16 16:08:33
Message-ID: 534EAB01.80405@linos.es
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On 16/04/14 17:57, Heikki Linnakangas wrote:
> On 04/16/2014 06:13 PM, Linos wrote:
>> I thought that Postgresql would optimize out joins on columns I
>> don't ask for when I use the view but it doesn't, this query:
>
> It doesn't, because it would be wrong. It still has to check that the tables have a matching row (or multiple matching rows).
>
> If you use LEFT JOINs instead, and have a unique index on all the ID columns, then the planner can do what you expected and leave out the joins.
>
> - Heikki
>
>

You are right, I knew I was forgetting something important but I didn't know what was, thank you Heikki.

Regards,
Miguel Angel.

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Nick Eubank 2014-04-16 16:35:12 Re: Workaround for working_mem max value in windows?
Previous Message Heikki Linnakangas 2014-04-16 15:57:21 Re: unneeded joins on view