Re: Using indexUnchanged with nbtree

Поиск
Список
Период
Сортировка
От Simon Riggs
Тема Re: Using indexUnchanged with nbtree
Дата
Msg-id CANbhV-FV4ivYD4OsJZ0e22F0iWBL6RKDdRkZP9Et3jAcS=6MeA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Using indexUnchanged with nbtree  (Peter Geoghegan <pg@bowt.ie>)
Ответы Re: Using indexUnchanged with nbtree  (Peter Geoghegan <pg@bowt.ie>)
Список pgsql-hackers
On Wed, Jun 23, 2021 at 5:17 PM Peter Geoghegan <pg@bowt.ie> wrote:
>
> On Mon, Jun 21, 2021 at 5:31 AM Simon Riggs
> <simon.riggs@enterprisedb.com> wrote:
> > Seems like we can skip the uniqueness check if indexUnchanged, which
> > will speed up non-HOT UPDATEs on tables with B-Trees.
>
> I thought about doing this myself. Never got as far as thinking about
> the correctness implications in detail.
>
> One thing that I'm concerned about is LP_DEAD bit setting inside
> _bt_check_unique(), which isn't going to take place when the
> optimization from the patch is applied. That definitely used to be way
> more important than kill_prior_tuple-based LP_DEAD bit setting, which
> has real problems with non-HOT updates [1]. _bt_check_unique() clearly
> makes up for that in the case of unique indexes, at least for many
> years.
>
> On the other hand my thinking here might well be outdated, because of
> course bottom-up index deletion exists now. You're using
> indexUnchanged here, which is used to trigger bottom-up index deletion
> passes. Maybe that's enough for it to not matter now, meaning that the
> LP_DEAD bit stuff is not a real blocker here. Offhand I'm quite
> unsure.

You're right that skipping the check might also skip killing a prior
row version, but it doesn't prevent later scans from killing them, so
there is no correctness aspect to that.

In the case of a non-HOT UPDATE the backend will see the index entry
for the old row version and then check it, pointlessly. Since that has
just been modified, that won't ever be killed, so skipping the check
makes sense in those cases.

-- 
Simon Riggs                http://www.EnterpriseDB.com/



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: Pipeline mode and PQpipelineSync()
Следующее
От: Peter Geoghegan
Дата:
Сообщение: Re: Using indexUnchanged with nbtree