From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Guillaume Lelarge <guillaume@lelarge.info>
To: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: PostgreSQL General <pgsql-general@postgresql.org>
Subject: Re: Weird planner issue on a standby
Date: Wed, 12 Oct 2022 15:43:51 +0200
Message-ID: <a4f4f4ea7832fcec3e4c0b2331b99af455d38f2b.camel@cybertec.at> (raw)
In-Reply-To: <CAECtzeWJaWRD93rneaCTQFpLZoMAfpBMvWa_qmJy6xc30ZOEAw@mail.gmail.com>
References: <418848.1665505048@sss.pgh.pa.us>
<20221011162736.cd2h5ajdbhtwdc4l@alvherre.pgsql>
<CAECtzeWVbyOL6gs793vu2zvF50H4LtoB4n6VTm9h9zcnY0J8iw@mail.gmail.com>
<CAECtzeU6R1k7+pHUpwhH2Ap5RQNVsM7JDna2pne1vnkft4K+ZQ@mail.gmail.com>
<CAECtzeWJaWRD93rneaCTQFpLZoMAfpBMvWa_qmJy6xc30ZOEAw@mail.gmail.com>
On Wed, 2022-10-12 at 10:51 +0200, Guillaume Lelarge wrote:
> Just finished my phone call. So, they definitely have their performance back. All they did was a VACUUM on two tables.
>
> If I understand correctly, during "normal" operations, some information is stored on the primary
> and sent to standbys. For some reason, only the primary take them into account, standbys ignore them.
> That would explain why, when we promoted a standby without doing anything else, it had much better
> performance. VACUUM fixes the issue on a standby, probably by storing this information in a different
> way. After VACUUM, standbys stop ignoring this information, which helps get the performance back.
>
> That sounds like a plausible explanation. I still have questions if you don't mind:
> * what is this information?
> * where is it stored? my guess would be indexes
> * why is it ignored on standbys and used on primary?
That sounds indeed like killed (LP_DEAD) index tuples on the primary.
Peter says they are ignored on the standby anyway, so on the standby
PostgreSQL went through a lot of index entries pointing to dead table
tuples, and it took a long time to find the maximal entry in the table,
which is done by the optimizer.
VACUUM removed those dead tuples and their associated index entries
on both primary and standby.
Yours,
Laurenz Albe
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: laurenz.albe@cybertec.at, guillaume@lelarge.info, alvherre@alvh.no-ip.org, tgl@sss.pgh.pa.us
Subject: Re: Weird planner issue on a standby
In-Reply-To: <a4f4f4ea7832fcec3e4c0b2331b99af455d38f2b.camel@cybertec.at>
References: <418848.1665505048@sss.pgh.pa.us> <20221011162736.cd2h5ajdbhtwdc4l@alvherre.pgsql> <CAECtzeWVbyOL6gs793vu2zvF50H4LtoB4n6VTm9h9zcnY0J8iw@mail.gmail.com> <CAECtzeU6R1k7+pHUpwhH2Ap5RQNVsM7JDna2pne1vnkft4K+ZQ@mail.gmail.com> <CAECtzeWJaWRD93rneaCTQFpLZoMAfpBMvWa_qmJy6xc30ZOEAw@mail.gmail.com> <a4f4f4ea7832fcec3e4c0b2331b99af455d38f2b.camel@cybertec.at>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox