public inbox for [email protected]  
help / color / mirror / Atom feed
From: Andrei Lepikhov <[email protected]>
To: Maxim Boguk <[email protected]>
Cc: [email protected]
Cc: Tom Lane <[email protected]>
Cc: David Rowley <[email protected]>
Subject: Re: inefficient/wrong plan cache mode selection for queries with partitioned tables (postgresql 17)
Date: Mon, 12 May 2025 19:22:05 +0200
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAK-MWwSgP2_br2jHtZSWYEH-T9tDx73LxqkNez-0kmck_wk=xQ@mail.gmail.com>
References: <CAK-MWwS_2UwF7XPy-8XpcVqUjEveDjDQRbXxPyzvJM+ooWeh9A@mail.gmail.com>
	<[email protected]>
	<CAK-MWwRP+OsZhEi5LGZcsWZikMj5+cCmVmK9oKgssFViF13NCQ@mail.gmail.com>
	<[email protected]>
	<CAK-MWwSgP2_br2jHtZSWYEH-T9tDx73LxqkNez-0kmck_wk=xQ@mail.gmail.com>

On 12/5/2025 16:04, Maxim Boguk wrote:
> On Mon, May 12, 2025 at 4:48 PM Andrei Lepikhov <[email protected] 
>     It is not hard to write such a tiny extension. As I see, the only extra
>     stored "C" procedure is needed to set up force-plan-type flag employing
>     FetchPreparedStatement(). The rest of the code - querying
>     pg_stat_statements and switching between plan types may be written in
>     plpgsql.
> 
>     If I'm not mistaken, it will work with all PG versions that are
>     currently in support. What do you think?
> 
> 
> Such extension would be very useful (and in general - the solution based 
> on the actual execution data - seems more stable/predictable than the 
> plan cost based selection which is currently used by postgresql).
Okay, as far as I can see now, it costs a couple of weeks to develop. It 
would be more profitable in terms of speed and usage in older versions 
than any core patch.
What's more, if, as you predict, it will work, it may provide a 
rationale for opening the entire plan cache for extensions and allow a 
wide audience to impact the extended protocol (and query plans in stored 
procedures) in many curious ways.
As I may envision, a dummy routine providing a link to the 
saved_plan_list will spend a few lines of code. A subscription to cached 
statements may cost more time and effort but seems even more profitable.

-- 
regards, Andrei Lepikhov





view thread (16+ messages)  latest in thread

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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected], [email protected]
  Subject: Re: inefficient/wrong plan cache mode selection for queries with partitioned tables (postgresql 17)
  In-Reply-To: <[email protected]>

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

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