From: | Merlin Moncure <mmoncure(at)gmail(dot)com> |
---|---|
To: | Peter van Hardenberg <pvh(at)pvh(dot)ca> |
Cc: | postgres performance list <pgsql-performance(at)postgresql(dot)org> |
Subject: | Re: Repeat execution of stable expressions |
Date: | 2012-03-06 15:00:50 |
Message-ID: | CAHyXU0wPD00FQJAw3Yx3MhKiEthWtf07eeATNGOczK=ase1sfw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
On Mon, Mar 5, 2012 at 6:41 PM, Peter van Hardenberg <pvh(at)pvh(dot)ca> wrote:
> On Mon, Mar 5, 2012 at 3:15 PM, Merlin Moncure <mmoncure(at)gmail(dot)com> wrote:
>> I've complained many times that
>> select (f()).*;
>>
>> will execute f() once for each returned field of f() since the server
>> essentially expands that into:
>>
>> select f().a, f().b;
>>
>
> oh, this is why we expand rows inside a WITH statement.
>
> it should probably be fixed, but you should find something like
>
> WITH fn AS SELECT f(),
> SELECT (fn).a, (fn).b
>
> will make your life better
sure, but WITH is an optimization fence. I use a lot of views, and if
you wrap your view with WITH, then your quals won't get pushed
through. ditto if you use the 'OFFSET 0' hack to keep the subquery
from being flattened out.
merlin
From | Date | Subject | |
---|---|---|---|
Next Message | Jan Otto | 2012-03-06 16:21:45 | Re: Repeat execution of stable expressions |
Previous Message | Rory Campbell-Lange | 2012-03-06 11:12:19 | Re: Advice sought : new database server |