On 21 April 2011 12:13, Josh Berkus <josh@xxxxxxxxxxxx> wrote: >> Emphasis on "always". If the result of the function, given the same >> argument values, can be different after a SET, then it doesn't qualify >> for immutability. At least, that's my understanding. > > Hmmmm. But within the context of the query plan itself, the results of > that expression are going to be constant. That is, for a given query > execution, it's always going to be the same comparison. > You may be thinking of the STABLE volatility level. It requires that the results of the function are the same for the same inputs, within the same transaction. "STABLE indicates that the function cannot modify the database, and that within a single table scan it will consistently return the same result for the same argument values, but that its result could change across SQL statements. This is the appropriate selection for functions whose results depend on database lookups, parameter variables (such as the current time zone), etc." Cheers, BJ -- Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance