Re: performance of sql and plpgsql functions - Mailing list pgsql-performance

From Julius Tuskenis
Subject Re: performance of sql and plpgsql functions
Date
Msg-id bd1aaef4-4c86-4ff0-b42a-65463b5c2ad2@gmail.com
Whole thread Raw
In response to Re: performance of sql and plpgsql functions  (Philip Semanchuk <philip@americanefficient.com>)
Responses Re: performance of sql and plpgsql functions  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-performance
On 2024-06-17 15:59, Philip Semanchuk wrote:

On Jun 17, 2024, at 5:35 AM, Julius Tuskenis <julius.tuskenis@gmail.com> wrote:


Isn't PosgreSQL supposed to inline simple SQL functions that are stable or immutable?
Postgres inlines SQL functions under certain conditions:
https://wiki.postgresql.org/wiki/Inlining_of_SQL_functions

One of those conditions is "the function is not SECURITY DEFINER”. It looks like yours is defined that way, so that might be why it’s not being inlined. 

Hope this helps
Philip

Thank You, Philip.

The link you've provided helps a lot explaining why the body of my SQL function is not inlined.

Any thoughts on why the execution times differ so much? I see planning of a plain SQL is 0.550ms. So I expect the SQL function to spend that time planning (inside), but I get 50ms (100 times longer).


Regards,

Julius Tuskenis

pgsql-performance by date:

Previous
From: Philip Semanchuk
Date:
Subject: Re: performance of sql and plpgsql functions
Next
From: Pavel Stehule
Date:
Subject: Re: performance of sql and plpgsql functions