"Craig A. James" <[EMAIL PROTECTED]> writes:
> But the weird thing is that, in spite of flattening, which would appear to
> make the queries equivalent, the function gets called in one case, and not in
> the other.
No, nothing particularly weird about it. ORDER BY in a subselect
acts as an "opt
Greg Stark wrote:
However that's not enough to explain what you've shown. How about you show the
actual query and actual plan you're working with? The plan you've shown can't
result from the query you sent.
Mea culpa, sort of. But ... in fact, the plan I sent *was* from query I sent, with the
"Craig A. James" <[EMAIL PROTECTED]> writes:
> This doesn't seem right to me -- how can the optimizer possibly know that a
> function doesn't have a side effect, as in my case? Functions could do all
> sorts of things, such as logging activity, filling in other tables, etc, etc.
The optimizer ca
On Sun, Jun 11, 2006 at 10:18:20AM -0700, Craig A. James wrote:
> This doesn't seem right to me -- how can the optimizer possibly know that a
> function doesn't have a side effect, as in my case? Functions could do all
> sorts of things, such as logging activity, filling in other tables, etc,
>
"Craig A. James" <[EMAIL PROTECTED]> writes:
>select count(1) from (select foo_init(value) from foo_init_table order by
> value_id) as foo;
> And indeed, it count() returns 800, as expected. But my function foo_init()
> never gets called!
Really? With the ORDER BY in there, it does get ca
On Sun, Jun 11, 2006 at 10:18:20AM -0700, Craig A. James wrote:
> This works well, but it requires me to actually retrieve the function's
> value 800 times.
Is this actually a problem?
> So I thought I'd be clever:
>
> select count(1) from (select foo_init(value) from foo_init_table order by
My application has a function, call it "foo()", that requires initialization from a table
of about 800 values. Rather than build these values into the C code, it seemed like a good idea to
put them on a PG table and create a second function, call it "foo_init()", which is
called for each value