Re: Does IMMUTABLE property propagate?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Louis-David Mitterrand <vindex+lists-pgsql-sql(at)apartia(dot)org>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Does IMMUTABLE property propagate?
Date: 2010-03-25 14:35:26
Message-ID: 16800.1269527726@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Louis-David Mitterrand <vindex+lists-pgsql-sql(at)apartia(dot)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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Leif Biberg Kristensen 2010-03-25 15:16:53 Plpgsql: Iterating through a string of parameters
Previous Message David Harel 2010-03-25 14:02:43 Capacity planning.