Re: inefficient/wrong plan cache mode selection for queries with partitioned tables (postgresql 17) - Mailing list pgsql-performance

From Andrei Lepikhov
Subject Re: inefficient/wrong plan cache mode selection for queries with partitioned tables (postgresql 17)
Date
Msg-id b7da2330-1054-4bb8-939a-cb05d377f70f@gmail.com
Whole thread Raw
In response to inefficient/wrong plan cache mode selection for queries with partitioned tables (postgresql 17)  (Maxim Boguk <maxim.boguk@gmail.com>)
Responses Re: inefficient/wrong plan cache mode selection for queries with partitioned tables (postgresql 17)
List pgsql-performance
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



pgsql-performance by date:

Previous
From: Maxim Boguk
Date:
Subject: inefficient/wrong plan cache mode selection for queries with partitioned tables (postgresql 17)
Next
From: Maxim Boguk
Date:
Subject: Re: inefficient/wrong plan cache mode selection for queries with partitioned tables (postgresql 17)