Re: Query Performance Degradation Due to Partition Scan Order – PostgreSQL v17.6 - Mailing list pgsql-hackers

From Andrei Lepikhov
Subject Re: Query Performance Degradation Due to Partition Scan Order – PostgreSQL v17.6
Date
Msg-id 17c0dab3-5995-4c18-9354-400803f967df@gmail.com
Whole thread Raw
In response to Re: Query Performance Degradation Due to Partition Scan Order – PostgreSQL v17.6  (Vivek Gadge <vvkgadge56@gmail.com>)
List pgsql-hackers
On 8/9/2025 13:39, Vivek Gadge wrote:
> 
> For example, when a query runs on a partitioned table, PostgreSQL scans 
> partitions in the order they were created or attached to the parent 
> table. In our case (monthly partitions from January through September), 
> this means that queries looking for recent data (e.g., September) may 
> experience additional overhead. PostgreSQL evaluates the older 
> partitions first, checking their constraints and in some cases probing 
> their indexes, before reaching the later partitions that actually 
> contain the needed data.
> 
> As a result, while the query results are correct, the execution time 
> increases due to unnecessary work on irrelevant partitions. This 
> performance impact is more noticeable when the target partition is at 
> the end of the scan order and pruning cannot fully eliminate the earlier 
> partitions.
The case looks straightforward. But just to be sure that we are on the 
same page, could you provide a synthetic DB example and a query 
representing the exact problem you are going to resolve?

-- 
regards, Andrei Lepikhov



pgsql-hackers by date:

Previous
From: Holger Hoffstätte
Date:
Subject: [PATCH] jit: fix build with LLVM-21
Next
From: Chao Li
Date:
Subject: Re: Optimize JsonbContainerTypeName by reordering type checks