| From: | Thierry Henrio <thierry(dot)henrio(at)gmail(dot)com> |
|---|---|
| To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
| Cc: | pgsql-general(at)lists(dot)postgresql(dot)org |
| Subject: | Re: plan for function returning table combined with condition |
| Date: | 2022-07-21 08:33:57 |
| Message-ID: | CAMPYKo0wMENLYd9-Q922AdkwrZu0X2Xiq9D2c=jNEXqbaZCh0Q@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On Wed, Jul 20, 2022 at 8:39 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> You want this SQL function to be inlined, but it isn't being.
> I think the reason is that (by default) it's VOLATILE, and
> inline_set_returning_function doesn't like that:
>
> * Forget it if the function is not SQL-language or has other
> showstopper
> * properties. In particular it mustn't be declared STRICT, since we
> * couldn't enforce that. It also mustn't be VOLATILE, because that is
> * supposed to cause it to be executed with its own snapshot, rather
> than
> * sharing the snapshot of the calling query. We also disallow
> returning
> * SETOF VOID, because inlining would result in exposing the actual
> result
> * of the function's last SELECT, which should not happen in that case.
>
> So try adding STABLE to the function definition.
>
Indeed, when I add STABLE to function, then planner uses index (same plan
as (B) in original post).
Thanks Tom.
, Thierry
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Dean Rasheed | 2022-07-21 08:41:30 | Re: [PATCH] Introduce array_shuffle() and array_sample() |
| Previous Message | Daulat | 2022-07-21 08:15:50 | Re: More than one Cluster on single server (single instance) |