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

From Ashutosh Bapat
Subject Re: Query Performance Degradation Due to Partition Scan Order – PostgreSQL v17.6
Date
Msg-id CAExHW5tAjMaoobDrn_FGwbGCqio_jCw=xJ8LYADruBcaG7XCjA@mail.gmail.com
Whole thread Raw
In response to Query Performance Degradation Due to Partition Scan Order – PostgreSQL v17.6  (Vivek Gadge <vvkgadge56@gmail.com>)
Responses Re: Query Performance Degradation Due to Partition Scan Order – PostgreSQL v17.6
Re: Query Performance Degradation Due to Partition Scan Order – PostgreSQL v17.6
List pgsql-hackers
On Mon, Sep 8, 2025 at 4:01 AM Vivek Gadge <vvkgadge56@gmail.com> wrote:
>
> Hi Team,
>
> We are currently experiencing performance issues related to partition scanning on a heavily used table in our
PostgreSQLv17.6 database. 
>
> The table is partitioned monthly (e.g., transactions_jan25, transactions_feb25, …, transactions_sept25). We’ve
observedthat PostgreSQL scans these partitions in the order they were attached (January through September). 
>
> This behavior is leading to inefficient query performance when accessing recent data (e.g., August or September), as
olderpartitions are being scanned first — adding unnecessary overhead. Since PostgreSQL does not provide a built-in
settingto prioritize scanning partitions in descending order, we’re exploring ways to address this. 
>
> Could you please advise on:
>
> How to optimize partition scanning so that recent partitions are scanned first, and
>
> Any recommended best practices or workarounds to improve performance in such scenarios.
>
> Looking forward to your guidance.
>
> Thank you
>

Can you please describe how the query performance is affected because
of the order in which partitions are scanned?

--
Best Wishes,
Ashutosh Bapat



pgsql-hackers by date:

Previous
From: Zsolt Parragi
Date:
Subject: Re: OAuth client code doesn't work with Google OAuth
Next
From: Richard Guo
Date:
Subject: Re: plan shape work