pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andreas Pflug <Andreas.Pflug@web.de>
To: pgsql-performance@postgresql.org
Subject: Re: inefficient query plan with left joined view
Date: Tue, 28 Jan 2003 20:31:46 +0100
Message-ID: <3E36DAA2.4010003@web.de> (raw)
In-Reply-To: <22633.1043778607@sss.pgh.pa.us>
References: <3E36B4F2.1020506@web.de>
	<22633.1043778607@sss.pgh.pa.us>

Tom Lane wrote:

>The subquery isn't pulled up because it doesn't pass the
>has_nullable_targetlist test in src/backend/optimizer/plan/planner.c.
>If we did flatten it, then references to calc_col wouldn't correctly
>go to NULL when the LEFT JOIN should make them do so --- they'd be
>22 all the time.
>
>As the notes in that routine say, it could be made smarter: strict
>functions of nullable variables could be allowed.  So if your real
>concern is not '22' but something like 'othercol + 22' then this is
>fixable.
>
>			regards, tom lane
>
>  
>
Tom,

actually my views do use calculated columns (mostly concated strings, 
e.g. full name from title/1st/last name). As the example shows even 
columns that are never used will be taken into account when checking 
has_nullable_targetlist. Unfortunately I have a lot of views containing 
views which containing.... delivering a lot more columns than needed. 
But they are checked anyway...

I'd expect the parser to look at the join construction only to find out 
about available data. Why should the selected (and even unselected) 
columns be evaluated if the join delivers no result? Maybe this can be 
achieved by checking only JOIN ON/WHERE columns with 
has_nullable_targetlist?



Regards,
Andreas




view thread (4+ messages)  latest in thread

Message-ID: <3E36DAA2.4010003@web.de>
Permalink:  ../3E36DAA2.4010003@web.de/
Also on:    postgresql.org/message-id/3E36DAA2.4010003@web.de

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: Andreas.Pflug@web.de
  Subject: Re: inefficient query plan with left joined view
  In-Reply-To: <3E36DAA2.4010003@web.de>
  References: <3E36B4F2.1020506@web.de> <22633.1043778607@sss.pgh.pa.us> <3E36DAA2.4010003@web.de>

* 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