Re: unstable query plan on pg 16,17,18

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Attila Soki <atiware(at)gmx(dot)net>, pgsql-performance(at)postgresql(dot)org
Subject: Re: unstable query plan on pg 16,17,18
Date: 2026-02-23 09:41:57
Message-ID: e94e4d006975792d72e667bbd0499f9ddec4ed58.camel@cybertec.at
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Mon, 2026-02-23 at 10:37 +0100, Attila Soki wrote:
> When upgrading from PostgreSQL 14.4, I noticed that one of my somewhat complex
> analytical queries sometimes gets an inefficient plan under PostgreSQL 16, 17, and 18.
> Under 14.4, the query runs with a stable plan and completes in 19 to 22 seconds.
> In newer versions, the plan seems to be unstable, sometimes the query completes
> in 17 to 20 seconds, sometimes it runs for 5 to 18 minutes with the inefficient plan.
> This also happens even if the data is not significantly changed.

This is very likely owing to a bad estimate.

Could you turn on "track_io_timing" and send us the EXPLAIN (ANALYZE, BUFFERS) output
for both the good and the bad plan?

Yours,
Laurenz Albe

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Nyasha Chigwamba 2026-02-23 10:52:05 Re: LATERAL subquery predicate pushdown: filter applied after JSON construction instead of inside join (PG 18)
Previous Message Attila Soki 2026-02-23 09:37:01 unstable query plan on pg 16,17,18