Re: Query planner instability on large append-only table with heavy same-day inserts

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Giriraj Sharma <giriraj(dot)sharma27(at)gmail(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Query planner instability on large append-only table with heavy same-day inserts
Date: 2025-10-28 13:02:17
Message-ID: 48cacb3c6e564e83ff67d7925d75488b79d74dba.camel@cybertec.at
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 2025-10-28 at 12:06 +0530, Giriraj Sharma wrote:
> We are running into query planner instability on an append-only table that records daily commit information.
> The workload is heavily skewed toward the current day’s data, and query performance deteriorates periodically until we run ANALYZE.

The best approach is to run autoanalyze often enough, either by reducing
autovacuum_analyze_scale_factor for the table or (as you suggested) by
setting the parameter to 0 and using only autovacuum_analyze_threshold.

There is no way to force a certain plan in PostgreSQL, unless you are
using the pg_hint_plan extension.

Yours,
Laurenz Albe

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Greg Sabino Mullane 2025-10-28 14:46:39 Re: Index (primary key) corrupt?
Previous Message Wim Rouquart 2025-10-28 10:25:01 RE: Index (primary key) corrupt?