Re: Does IMMUTABLE property propagate? - Mailing list pgsql-sql

From Tom Lane
Subject Re: Does IMMUTABLE property propagate?
Date
Msg-id 16800.1269527726@sss.pgh.pa.us
Whole thread Raw
In response to Re: Does IMMUTABLE property propagate?  (Louis-David Mitterrand <vindex+lists-pgsql-sql@apartia.org>)
Responses Re: Does IMMUTABLE property propagate?
List pgsql-sql
Louis-David Mitterrand <vindex+lists-pgsql-sql@apartia.org> writes:
> Hmm, that's interesting. So for simple functions (like my example) it is
> better to write them in plain sql? And in that case no 'immutable' flag
> is necessary?

If it's just a simple SQL expression, then yes write it as a SQL
function.  The planner can "inline" those, eliminating the call overhead
that you'll pay with a plpgsql function.

When you're intending to have a SQL function be inlined, it's probably
best not to mark it as either IMMUTABLE or STRICT --- that doesn't buy
anything and it can complicate matters as to whether inlining is legal.
        regards, tom lane


pgsql-sql by date:

Previous
From: David Harel
Date:
Subject: Capacity planning.
Next
From: Leif Biberg Kristensen
Date:
Subject: Re: Plpgsql: Iterating through a string of parameters