Re: Dealing with SeqScans when Time-based Partitions Cut Over

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Greg Sabino Mullane <htamfids(at)gmail(dot)com>, Matthew Planchard <msplanchard(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Dealing with SeqScans when Time-based Partitions Cut Over
Date: 2025-12-19 17:42:34
Message-ID: 64ccdcb7b15a17cbf610854e51cd8235c246cca8.camel@cybertec.at
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, 2025-12-19 at 09:49 -0500, Greg Sabino Mullane wrote:
> If this is still an issue after you check David's theory about premature analyzing,
> another approach is to pre-populate and pre-analyze future tables. Something like this:
>
> * disable autovac on the future table
> * detach the table from the main partition
> * insert a few hundred thousand rows into it, then run analyze on it
> * can pull rows from a current table, or just use random data on a key column- whatever is enough to generate "good" stats
> * delete the rows - the stats will remain
> * reattach the table
> * enable autovac if you like; I would not

I doubt that that is good advice. For one, wrong statistics are not necessarily
better than no statistics. Disabling autovacuum is dangerous - and re-enabling
it would trigger another autovacuum, which would undo your efforts.
*Not* re-enabling autovacuum is not an option, unless you schedule explicit
VACUUM runs on the partition.

Yours,
Laurenz Albe

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Igor Korot 2025-12-19 18:49:26 Fwd: PQexecPrepared() question
Previous Message Christoph Moench-Tegeder 2025-12-19 17:05:44 Re: How to get single table data from backup