Re: Performance after restart/reboot pre-Analyze

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: David Fogarty <dfogarty(at)icsusa(dot)com>
Cc: pgsql-novice(at)lists(dot)postgresql(dot)org
Subject: Re: Performance after restart/reboot pre-Analyze
Date: 2024-03-28 17:32:26
Message-ID: 202403281732.p3cxllpbx7qf@alvherre.pgsql
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On 2024-Mar-28, David Fogarty wrote:

> It seems like whenever I restart my database server performance is
> quite bad until an Analyze has been performed. I expect this is due to
> the query planner needing new stats, but that leads me to three
> questions:

How exactly are you restarting the database server? Statistics
collected by ANALYZE are lost on crashes or when recovery is run, so if
you're just hard-crashing your server, then ANALYZE is indeed necessary.
If that's what's happening, try not doing that -- use fast shutdown (not
immediate) and wait until it's finished before turning power off.

If you do need to crash your server (but why risk your data?), then
maybe vacuumdb --analyze-in-stages would be helpful.

Otherwise, a cold cache as others mentioned is the most likely
explanation.

--
Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/
"Doing what he did amounts to sticking his fingers under the hood of the
implementation; if he gets his fingers burnt, it's his problem." (Tom Lane)

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message James Creasy 2024-04-24 21:26:41 Hello, novice Postgres user, seg fault investigation
Previous Message Tom Lane 2024-03-28 15:52:59 Re: Performance after restart/reboot pre-Analyze