pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ron <ronljohnsonjr@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: right way of using case-expressions in plpgsql functions
Date: Sun, 15 Oct 2023 16:14:00 -0500
Message-ID: <3ca87218-264c-421b-8e2b-59cd93f48bb3@gmail.com> (raw)
In-Reply-To: <CAJFsatMhj1oX8kVcSUiTkEddk=Evh10NH9v=-Nxo8vD7xQ0mLg@mail.gmail.com>
References: <CAJFsatMhj1oX8kVcSUiTkEddk=Evh10NH9v=-Nxo8vD7xQ0mLg@mail.gmail.com>

On 10/15/23 11:19, Victor Dobrovolsky wrote:
[snip]
> The documentation states that after some executions of such functions the 
> plan should become generic.
> What is a generic plan for such a case and how would it work?

It's highly dependent on the query

When I see this happen (after we notice that a procedure starts taking a 
/long/ time), the query planner flips from a custom plan to a generic plan 
after about the fifth execution in a session of a function/procedure.

This will make it calculate the plan every time:
set plan_cache_mode = force_custom_plan;

-- 
Born in Arizona, moved to Babylonia.

view thread (8+ messages)  latest in thread

Message-ID: <3ca87218-264c-421b-8e2b-59cd93f48bb3@gmail.com>
Permalink:  ../3ca87218-264c-421b-8e2b-59cd93f48bb3@gmail.com/
Also on:    postgresql.org/message-id/3ca87218-264c-421b-8e2b-59cd93f48bb3@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: ronljohnsonjr@gmail.com
  Subject: Re: right way of using case-expressions in plpgsql functions
  In-Reply-To: <3ca87218-264c-421b-8e2b-59cd93f48bb3@gmail.com>
  References: <CAJFsatMhj1oX8kVcSUiTkEddk=Evh10NH9v=-Nxo8vD7xQ0mLg@mail.gmail.com> <3ca87218-264c-421b-8e2b-59cd93f48bb3@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox