Re: STABLE functions - Mailing list pgsql-hackers

From Tom Lane
Subject Re: STABLE functions
Date
Msg-id 15382.1051279304@sss.pgh.pa.us
Whole thread Raw
In response to STABLE functions  (Joachim Wieland <jwieland@kawo2.rwth-aachen.de>)
Responses Re: STABLE functions  (Joachim Wieland <jwieland@kawo2.rwth-aachen.de>)
List pgsql-hackers
Joachim Wieland <jwieland@kawo2.rwth-aachen.de> writes:
> I'm using 7.3.2 and encounter the problem that a SELECT query that uses
> a function with a constant argument is quite slow. The function is
> declared STABLE. Here's an example:

> SELECT ... FROM table WHERE col = f('xyz');

>> From what I read in the docs

> ( http://www.postgresql.org/docs/view.php?version=7.3&idoc=0&file=sql-createfunction.html )

> I thought that this function is only executed once when declared as
> STABLE,

You are mistaken.

If you'd declared it IMMUTABLE, then it would get constant-folded, but
that may or may not be suitable for your purpose.
        regards, tom lane



pgsql-hackers by date:

Previous
From: mlw
Date:
Subject: Re: close() vs. closesocket()
Next
From: Tom Lane
Date:
Subject: Re: close() vs. closesocket()