Re: Slow timestamp query after upgrading from Pg13 to Pg16

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Simon Windsor <simon(dot)windsor(at)cornfield(dot)me(dot)uk>, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, pgsql-general(at)postgresql(dot)org
Subject: Re: Slow timestamp query after upgrading from Pg13 to Pg16
Date: 2025-04-07 19:36:32
Message-ID: 9653cc7d-3275-4255-ba4d-fba3778f67e6@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 4/7/25 12:25, Simon Windsor wrote:
> Hi
>
> We used pg_dump|pg_restore to migrate the data.

Did you do an ANALYZE on the Postgres 16 instance after the pg_restore?

>
> The full explain plan is at https://explain.depesz.com/s/742M. The SQL
>
> explain (analyze, buffers) select count(*) from consignments where
> (req_status_tstamp >= '2025-03-28 00:00'::timestamp and
> req_status_tstamp <= '2025-03-28 01:00'::timestamp);
>
> takes 2-3s with the old Pg13 DB, and over a minute with Pg16

Do you have an EXPLAIN ANALYZE for the Postgres 13 case?

>
> After spending many hours looking at DB settings and Statistic settings
> I am at a loss/
>
> Simon
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Willy-Bas Loos 2025-04-07 20:32:55 Re: find replication slots that "belong" to a publication
Previous Message Simon Windsor 2025-04-07 19:25:28 Re: Slow timestamp query after upgrading from Pg13 to Pg16