Re: function not called if part of aggregate

From: Greg Stark <gsstark(at)mit(dot)edu>
To: "Craig A(dot) James" <cjames(at)modgraph-usa(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: function not called if part of aggregate
Date: 2006-06-11 18:00:38
Message-ID: 87ac8jfu7t.fsf@stark.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance


"Craig A. James" <cjames(at)modgraph-usa(dot)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

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Mario Splivalo 2006-06-11 21:42:20 Re: scaling up postgres
Previous Message Jim C. Nasby 2006-06-11 17:48:37 Re: function not called if part of aggregate