Re: Why is my function inlined only when STABLE?

From: Philip Semanchuk <philip(at)americanefficient(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL General <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Why is my function inlined only when STABLE?
Date: 2022-03-29 18:43:27
Message-ID: F391D389-A6C7-41B7-9A53-260632CBDC7B@americanefficient.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> On Mar 29, 2022, at 2:24 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Philip Semanchuk <philip(at)americanefficient(dot)com> writes:
>> I have a function that isn't being inlined, and I would appreciate help to understand why that's the case.
>
> I think the test methodology you used is faulty, because it does not
> distinguish between "inline-able" and "foldable to a constant".
> Given an immutable function applied to constant(s), the planner prefers
> to fold to a constant by just executing the function. The inline-ing
> transformation is considered only when that case doesn't apply.

Excellent point, thank you. Now I understand. I was trying to write an inlining demo for my colleagues, and I simplified my example one step too far by using a constant.

I really appreciate the help!

Cheers
Philip

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Paul Jungwirth 2022-03-30 01:30:46 psql -f and PAGER
Previous Message Tom Lane 2022-03-29 18:24:41 Re: Why is my function inlined only when STABLE?