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


-- 
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)  latest in thread

Message-ID: <534EA861.3020204@vmware.com>
Permalink:  ../534EA861.3020204@vmware.com/
Also on:    postgresql.org/message-id/534EA861.3020204@vmware.com

 · 

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: hlinnakangas@vmware.com, info@linos.es
  Subject: Re: unneeded joins on view
  In-Reply-To: <534EA861.3020204@vmware.com>

* 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