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

From: Andrei Lepikhov <lepihov(at)gmail(dot)com>
To: Attila Soki <atiware(at)gmx(dot)net>, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: unstable query plan on pg 16,17,18
Date: 2026-02-27 15:35:31
Message-ID: 091eef0e-0271-47d1-aa47-439284e3f316@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On 27/2/26 16:00, Attila Soki wrote:
> On 27 Feb 2026, at 09:15, Andrei Lepikhov <lepihov(at)gmail(dot)com> wrote:
> I dont know the inner workings of analyze, is that normal that executing
> analyze on unchanged data can flip the plan? Does analyze select a
> random set of rows?

Yes, this is completely normal because ANALYZE works in a random way.
You can try using the Join-Order-Benchmark to see how running the
ANALYZE command can change the execution time of the same query,
sometimes by as much as ten times.

--
regards, Andrei Lepikhov,
pgEdge

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Haritabh Gupta 2026-03-04 10:02:11 Re: proposal: schema variables
Previous Message Attila Soki 2026-02-27 15:00:25 Re: unstable query plan on pg 16,17,18