Re: Why overhead of SPI is so large?

From: Konstantin Knizhnik <k(dot)knizhnik(at)postgrespro(dot)ru>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: "Tsunakawa, Takayuki" <tsunakawa(dot)takay(at)jp(dot)fujitsu(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Why overhead of SPI is so large?
Date: 2019-08-23 09:05:30
Message-ID: 0fb4b4aa-7266-289e-be23-7ac5f8def42e@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 22.08.2019 18:56, Pavel Stehule wrote:
>
>
> čt 22. 8. 2019 v 17:51 odesílatel Konstantin Knizhnik
> <k(dot)knizhnik(at)postgrespro(dot)ru <mailto:k(dot)knizhnik(at)postgrespro(dot)ru>> napsal:
>
> Some more information...
> First of all I found out that marking PL/pgSQL function as
> immutable significantly increase speed of its execution:
> 19808 ms vs. 27594. It happens because exec_eval_simple_expr is
> taken snapshot if function is volatile (default).
> I wonder if PL/pgSQL compiler can detect that evaluated expression
> itself is actually immutable  and there is no need to take snapshot
> for each invocation of this function. Also I have tried yet
> another PL language - JavaScript, which is now new outsider,
> despite to the fact that
> v8 JIT compiler is very good.
>
>
> I have a plan to do some work in this direction. Snapshot is not
> necessary for almost buildin functions. If expr calls only buildin
> functions, then probably can be called without snapshot and without
> any work with plan cache.
>

I wonder if the following simple patch is correct?

--
Konstantin Knizhnik
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

Attachment Content-Type Size
plpgsql_exec_expr.patch text/x-patch 2.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2019-08-23 09:10:28 Re: Why overhead of SPI is so large?
Previous Message Dent John 2019-08-23 08:52:43 Re: (select query)/relation as first class citizen