From: Tom Lane <tgl@sss.pgh.pa.us>
To: Louis-David Mitterrand <vindex+lists-pgsql-sql@apartia.org>
Cc: pgsql-sql@postgresql.org
Subject: Re: Does IMMUTABLE property propagate?
Date: Thu, 25 Mar 2010 10:35:26 -0400
Message-ID: <16800.1269527726@sss.pgh.pa.us> (raw)
In-Reply-To: <20100325075405.GA17176@apartia.fr>
References: <4B91C184.4090906@venaver.info>
<407d949e1003060645i408e0648te67dfd722172f76a@mail.gmail.com>
<4B927FED.60209@venaver.info>
<4150.1267911115@sss.pgh.pa.us>
<20100325061616.GA4629@apartia.fr>
<162867791003250027q3cfc5ba9g59d56768aa4c4e5e@mail.gmail.com>
<20100325075405.GA17176@apartia.fr>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, vindex+lists-pgsql-sql@apartia.org
Subject: Re: Does IMMUTABLE property propagate?
In-Reply-To: <16800.1269527726@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox