pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Linos <info@linos.es>
To: Heikki Linnakangas <hlinnakangas@vmware.com>
To: pgsql-performance@postgresql.org
Subject: Re: unneeded joins on view
Date: Wed, 16 Apr 2014 18:08:33 +0200
Message-ID: <534EAB01.80405@linos.es> (raw)
In-Reply-To: <534EA861.3020204@vmware.com>
References: <534E9E14.5000304@linos.es>
	<534EA861.3020204@vmware.com>
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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.


-- 
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance



view thread (3+ messages)

Message-ID: <534EAB01.80405@linos.es>
Permalink:  ../534EAB01.80405@linos.es/
Also on:    postgresql.org/message-id/534EAB01.80405@linos.es

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: info@linos.es, hlinnakangas@vmware.com
  Subject: Re: unneeded joins on view
  In-Reply-To: <534EAB01.80405@linos.es>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox