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

From Vivek Gadge
Subject Query Performance Degradation Due to Partition Scan Order – PostgreSQL v17.6
Date
Msg-id CAK+uD7iy0jZpThuRki3ANqBMScKRSDJm1rc85KdqC67xuYbJPg@mail.gmail.com
Whole thread Raw
Responses Re: Query Performance Degradation Due to Partition Scan Order – PostgreSQL v17.6
List pgsql-hackers
Hi Team,

We are currently experiencing performance issues related to partition scanning on a heavily used table in our PostgreSQL v17.6 database.

The table is partitioned monthly (e.g., transactions_jan25, transactions_feb25, …, transactions_sept25). We’ve observed that 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 older partitions are being scanned first — adding unnecessary overhead. Since PostgreSQL does not provide a built-in setting to 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

pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: POC: enable logical decoding when wal_level = 'replica' without a server restart
Next
From: Amit Kapila
Date:
Subject: Re: Allow logical replication in the same cluster