From: | Andrei Lepikhov <lepihov(at)gmail(dot)com> |
---|---|
To: | Vivek Gadge <vvkgadge56(at)gmail(dot)com>, Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com> |
Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Query Performance Degradation Due to Partition Scan Order – PostgreSQL v17.6 |
Date: | 2025-09-08 13:27:27 |
Message-ID: | 17c0dab3-5995-4c18-9354-400803f967df@gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Chao Li | 2025-09-08 13:27:29 | Re: Optimize JsonbContainerTypeName by reordering type checks |
Previous Message | Junwang Zhao | 2025-09-08 13:07:55 | Re: Reduce "Var IS [NOT] NULL" quals during constant folding |