Re: Too many function calls in view with LEFT JOIN

From: Andreas Heiduk <Andreas(dot)Heiduk(at)web(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Too many function calls in view with LEFT JOIN
Date: 2006-05-31 19:42:16
Message-ID: 933433606@web.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hello!

Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote
>
> Andreas Heiduk <Andreas(dot)Heiduk(at)web(dot)de> writes:
> > If a view which calls a function is LEFT JOINed to a table but not all
> > result rows are matched by some criteria, then the function is called
> > for each row of the view nevertheless.
>
> > Note that this seems to happen only for left joins, not for a inner join.
>
> I believe that's because the column is required to go to NULL in an
> unjoined row. With a non-strict function, evaluating it after the join
> could yield wrong answers. Try making the function strict.

First: setting the function to STRICT really cuts down the number of function calls even with the SELECT via view.

But as far as I can tell both queries should always return the same results. So I don't understand why the STRICT does not matter in the first query but is necessary in the second one. Especially because the JOIN criterium is not affected by the function call.

Oh, and sorry that I forgot the version: "PostgreSQL 8.1.4 on i486-pc-linux-gnu, compiled by GCC cc (GCC) 4.0.4 20060507 (prerelease) (Debian 4.0.3-3)"

Best regards,
Andreas Heiduk

______________________________________________________________________
XXL-Speicher, PC-Virenschutz, Spartarife & mehr: Nur im WEB.DE Club!
Jetzt gratis testen! http://freemail.web.de/home/landingpad/?mc=021130

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2006-05-31 20:03:13 Re: Too many function calls in view with LEFT JOIN
Previous Message claus.pruefer 2006-05-31 16:54:04