Re: performance of sql and plpgsql functions

2024-06-18 Thread Julius Tuskenis
On 2024-06-17 17:24, Tom Lane wrote: Julius Tuskenis writes: EXPLAIN (ANALYZE, BUFFERS, VERBOSE)   SELECT     COALESCE(sum(mok_nepadengta), 0)   FROM     public.b_pardavimai     JOIN public.b_mokejimai ON (mok_pardavimas = pard_id)   WHERE     (pard_tipas = ANY('{1, 2, 6, 7}'))

Re: performance of sql and plpgsql functions

2024-06-17 Thread Tom Lane
Julius Tuskenis writes: > EXPLAIN (ANALYZE, BUFFERS, VERBOSE) >   SELECT >     COALESCE(sum(mok_nepadengta), 0) >   FROM >     public.b_pardavimai >     JOIN public.b_mokejimai ON (mok_pardavimas = pard_id) >   WHERE >     (pard_tipas = ANY('{1, 2, 6, 7}')) >     AND (mok_saskaita = 714196

Re: performance of sql and plpgsql functions

2024-06-17 Thread Pavel Stehule
po 17. 6. 2024 v 15:55 odesílatel Julius Tuskenis napsal: > On 2024-06-17 15:59, Philip Semanchuk wrote: > > On Jun 17, 2024, at 5:35 AM, Julius Tuskenis > wrote: > > > Isn't PosgreSQL supposed to inline simple SQL functions that are stable or > immutable? > > Postgres inlines SQL functions u

Re: performance of sql and plpgsql functions

2024-06-17 Thread Julius Tuskenis
On 2024-06-17 15:59, Philip Semanchuk wrote: On Jun 17, 2024, at 5:35 AM, Julius Tuskenis 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_f

Re: performance of sql and plpgsql functions

2024-06-17 Thread Philip Semanchuk
> On Jun 17, 2024, at 5:35 AM, Julius Tuskenis > 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

Re: performance of sql and plpgsql functions

2024-06-17 Thread Julius Tuskenis
Thank you Pavel for your input. You wrote: no, PLpgSQL functions are not inlined Yes, I understand that. I was referring to SQL functions (not plpgsql). Regards, Julius Tuskenis On 2024-06-17 12:44, Pavel Stehule wrote: po 17. 6. 2024 v 11:35 odesílatel Julius Tuskenis napsal: D

Re: performance of sql and plpgsql functions

2024-06-17 Thread Pavel Stehule
po 17. 6. 2024 v 11:35 odesílatel Julius Tuskenis napsal: > Dear Postgresql performance guru, > > For some reason on our client server a function written in SQL language > executes *100 times slower* than the one written in plpgsql... > > After updating to "PostgreSQL 12.18, compiled by Visual C+

performance of sql and plpgsql functions

2024-06-17 Thread Julius Tuskenis
Dear Postgresql performance guru, For some reason on our client server a function written in SQL language executes *100 times slower* than the one written in plpgsql... After updating to "PostgreSQL 12.18, compiled by Visual C++ build 1914, 64-bit" (from pg9.5) our client reported a performan