public inbox for [email protected]  
help / color / mirror / Atom feed
From: Andrei Lepikhov <[email protected]>
To: Maxim Boguk <[email protected]>
To: [email protected]
Subject: Re: inefficient/wrong plan cache mode selection for queries with partitioned tables (postgresql 17)
Date: Mon, 12 May 2025 14:08:21 +0200
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAK-MWwS_2UwF7XPy-8XpcVqUjEveDjDQRbXxPyzvJM+ooWeh9A@mail.gmail.com>
References: <CAK-MWwS_2UwF7XPy-8XpcVqUjEveDjDQRbXxPyzvJM+ooWeh9A@mail.gmail.com>

On 5/12/25 13:49, Maxim Boguk wrote:
> I suspect this situation should be quite common with queries over 
> partitioned tables (where planning time is usually quite a high).
> 
> Any suggestions what could be done there outside of using 
> force_generic_plan for a particular db user (which will kill performance 
> in other queries for sure)?
Thanks for this puzzle!
I suppose, in case generic planning is much faster than custom one, 
there are two candidates exist:
1. Touching the index during planning causes too much overhead - see 
get_actual_variable_range
2. You have a massive default_statistics_target for a table involved.

So, to clarify the problem, may you provide EXPLAIN (without analyze) 
with BUFFERS ON ?
Also, could you provide extra information on the statistics involved? 
For each column (I think created_at is the most important one), show the 
size of MCV and histogram arrays.

-- 
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]
  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