Re: function not called if part of aggregate - Mailing list pgsql-performance

From Greg Stark
Subject Re: function not called if part of aggregate
Date
Msg-id 87ac8jfu7t.fsf@stark.xeocode.com
Whole thread Raw
In response to function not called if part of aggregate  ("Craig A. James" <cjames@modgraph-usa.com>)
Responses Re: function not called if part of aggregate
List pgsql-performance
"Craig A. James" <cjames@modgraph-usa.com> 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 can know this if the user tells it so by marking the function
IMMUTABLE. If the function is marked VOLATILE then the optimizer can know it
might have side effects.

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.

--
greg

pgsql-performance by date:

Previous
From: "Jim C. Nasby"
Date:
Subject: Re: function not called if part of aggregate
Next
From: "Steinar H. Gunderson"
Date:
Subject: Re: scaling up postgres