pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michal <michal-ok@o2.pl>
To: Tom Lane <tgl@sss.pgh.pa.us>
To: Ken Tanzer <ken.tanzer@gmail.com>
Cc: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: PG-General Mailing List <pgsql-general@postgresql.org>
Subject: Re: Immutable function WAY slower than Stable function?
Date: Wed, 15 Aug 2018 01:40:17 +0200
Message-ID: <b3191dde-4775-dca6-81ea-d0760f3dd261@o2.pl> (raw)
In-Reply-To: <24954.1533658221@sss.pgh.pa.us>
References: <CAD3a31Vh6f5eLhK0kQL6b5mxr2Fc0qda1yW8YqTvDQRxcpg9jg@mail.gmail.com>
	<03120a03-75d0-ad6c-691c-35ca7e7fccfa@aklaver.com>
	<CAD3a31X3u8A2aqnOHcQG-dE_vaeC=jm+O2uAw8+svp5B0MxC+w@mail.gmail.com>
	<27336.1533609731@sss.pgh.pa.us>
	<CAD3a31Xu+XHf70HnWeS+rXEvBypOBihDNU1N8DOEaXB36HSi6Q@mail.gmail.com>
	<24954.1533658221@sss.pgh.pa.us>

On 2018.08.07 18:10, Tom Lane wrote:
> I've had a to-do item to rewrite and improve the SQL function cache
> mechanism for a long time, but I hadn't thought it was high priority.
> Maybe it should be.
>
> In the meantime, I think you could dodge the issue by converting either
> level of function into plpgsql.  Or just be careful about inline-ability
> of convenience wrappers.

I now remember I stumbled across this same problem last year when I 
needed an immutable unaccent() function for the purpose of creating a 
functional index. I simply wrapped unaccent(), which is stable, in an 
immutable custom function (and accepting the need to recreate the index 
in case when unaccent rules change). I can't remember the specifics but 
I was also surprised to learn that query execution plans were not 
optimized at all when the function was immutable and in some cases they 
were even slower than when the function was stable, quite contrary to 
all logic and to what the docs say. So I think it would be great if this 
issue were resolved in Postgres.




view thread (19+ messages)

Message-ID: <b3191dde-4775-dca6-81ea-d0760f3dd261@o2.pl>
Permalink:  ../b3191dde-4775-dca6-81ea-d0760f3dd261@o2.pl/
Also on:    postgresql.org/message-id/b3191dde-4775-dca6-81ea-d0760f3dd261@o2.pl

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: michal-ok@o2.pl, tgl@sss.pgh.pa.us, ken.tanzer@gmail.com, adrian.klaver@aklaver.com
  Subject: Re: Immutable function WAY slower than Stable function?
  In-Reply-To: <b3191dde-4775-dca6-81ea-d0760f3dd261@o2.pl>
  References: <CAD3a31Vh6f5eLhK0kQL6b5mxr2Fc0qda1yW8YqTvDQRxcpg9jg@mail.gmail.com> <03120a03-75d0-ad6c-691c-35ca7e7fccfa@aklaver.com> <CAD3a31X3u8A2aqnOHcQG-dE_vaeC=jm+O2uAw8+svp5B0MxC+w@mail.gmail.com> <27336.1533609731@sss.pgh.pa.us> <CAD3a31Xu+XHf70HnWeS+rXEvBypOBihDNU1N8DOEaXB36HSi6Q@mail.gmail.com> <24954.1533658221@sss.pgh.pa.us> <b3191dde-4775-dca6-81ea-d0760f3dd261@o2.pl>

* 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