Re: Why overhead of SPI is so large? - Mailing list pgsql-hackers

From Pavel Stehule
Subject Re: Why overhead of SPI is so large?
Date
Msg-id CAFj8pRAzmE2uA6hV=5pib0NJPnRrO580_oR09BBCFs_oezyimA@mail.gmail.com
Whole thread Raw
In response to Re: Why overhead of SPI is so large?  (Konstantin Knizhnik <k.knizhnik@postgrespro.ru>)
Responses Re: Why overhead of SPI is so large?
List pgsql-hackers


čt 22. 8. 2019 v 17:51 odesílatel Konstantin Knizhnik <k.knizhnik@postgrespro.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.

Pavel

Implementation
time (ms)
PL/v8
41550
PL/Lua32220
PL/pgSQL19808
C/SPI  9406
SQL  7399
SQL (JIT) 
  5532
С/coreAPI  2873
-- 
Konstantin Knizhnik
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company 

pgsql-hackers by date:

Previous
From: Konstantin Knizhnik
Date:
Subject: Re: Why overhead of SPI is so large?
Next
From: Kohei KaiGai
Date:
Subject: Re: Asymmetric partition-wise JOIN