Re: unneeded joins on view

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

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

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Linos 2014-04-16 16:08:33 Re: unneeded joins on view
Previous Message Roxanne Reid-Bennett 2014-04-16 15:42:02 Re: Approach to Data Summary and Analysis