pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Piotr Gasidło <quaker@barbara.eu.org>
Cc: pgsql-performance@postgresql.org
Subject: Re: Trouble with LEFT JOIN using VIEWS.
Date: Fri, 07 Dec 2007 10:36:04 -0500
Message-ID: <20269.1197041764@sss.pgh.pa.us> (raw)
In-Reply-To: <4759268C.6090508@barbara.eu.org>
References: <4759268C.6090508@barbara.eu.org>

=?ISO-8859-2?Q?Piotr_Gasid=B3o?= <quaker@barbara.eu.org> writes:
> I've just hit problem, that is unusual for me.

> View definition:
>   SELECT users.id, users.user_name, users.extra IS NOT NULL AS has_extra
>     FROM users;

What you've got here is a non-nullable target list, which creates an
optimization fence when used in the nullable side of an outer join.
The problem is that has_extra should read as NULL in the query output
for a sites_secure row that has no match in users_secure_with_has_extra,
but making users.extra go to null will not make that happen, so there's
a constraint on where the expression can be evaluated.  The current
planner has no way to deal with that except by restricting the plan
structure.

We have some ideas about how to fix this, but don't hold your breath
... it's going to take major surgery on the planner, AFAICS.

			regards, tom lane



view thread (2+ messages)

Message-ID: <20269.1197041764@sss.pgh.pa.us>
Permalink:  ../20269.1197041764@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/20269.1197041764@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, quaker@barbara.eu.org
  Subject: Re: Trouble with LEFT JOIN using VIEWS.
  In-Reply-To: <20269.1197041764@sss.pgh.pa.us>

* 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