Louis-David Mitterrand <vindex+lists-pgsql-...@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 -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql