public inbox for [email protected]
help / color / mirror / Atom feedFrom: Attila Soki <[email protected]>
To: Andrei Lepikhov <[email protected]>
To: [email protected]
Subject: Re: unstable query plan on pg 16,17,18
Date: Mon, 23 Feb 2026 18:03:33 +0100
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
<[email protected]>
<[email protected]>
> On 23 Feb 2026, at 16:54, Andrei Lepikhov <[email protected]> wrote:
>
> On 23/2/26 10:41, Laurenz Albe wrote:
>> 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?
>
> Since PG16, the optimiser changed a lot. So, there are plenty of possibilities that might happen - table statistics update, for example. So, we need at least EXPLAIN ANALYSE for 'good' and 'bad' cases to begin a discussion.
Hi Andrei,
see my previous answer:
https://www.postgresql.org/message-id/1695A676-062B-47C5-B302-91E2357DC874%40gmx.net
but here are the plans again:
In order to be able to publish the plans here, I have obfuscated the table and field names, but this is reversible, so I can provide more info if needed.
plan-ok:
https://explain.depesz.com/s/hQvM
plan-wrong:
https://explain.depesz.com/s/uLvl
regards,
Attila
view thread (25+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: unstable query plan on pg 16,17,18
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox