Re: Interesting case of IMMUTABLE significantly hurting performance

From: Nico Williams <nico(at)cryptonector(dot)com>
To: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
Cc: Olleg Samoylov <splarv(at)ya(dot)ru>, "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Interesting case of IMMUTABLE significantly hurting performance
Date: 2025-04-09 21:21:40
Message-ID: Z/bk5E6pqIBWTF3j@ubby
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Apr 09, 2025 at 10:50:00PM +0200, Laurenz Albe wrote:
> The IMMUTABLE function cannot be inlined because to_char() is not IMMUTABLE.

Q: Why would to_char() not be IMMUTABLE?

A: Because it makes use of locales, and I guess the guc-timezone GUC,
which could change if the expression is ultimately used in a PlPgSQL
fragment, or if it's in a prepared statement. (I think.)

That to_char is not immutable is not documented though. Though it's
clear when looking at the docs for the `jsonb_.*_tz()` functions.

Nico
--

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2025-04-09 21:43:11 Re: Interesting case of IMMUTABLE significantly hurting performance
Previous Message David G. Johnston 2025-04-09 21:06:12 Re: Interesting case of IMMUTABLE significantly hurting performance