From 5744001117c42b7e1bf7546a8daa2661cc9a42e6 Mon Sep 17 00:00:00 2001 From: Matthias van de Meent Date: Thu, 6 Jul 2023 13:32:09 +0200 Subject: [PATCH v1] Add documentation in README.HOT for handling summarizing indexes --- src/backend/access/heap/README.HOT | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/backend/access/heap/README.HOT b/src/backend/access/heap/README.HOT index 6fd1767f70..983d8017cf 100644 --- a/src/backend/access/heap/README.HOT +++ b/src/backend/access/heap/README.HOT @@ -126,14 +126,27 @@ whether it was part of a HOT chain or not. This allows space reclamation in advance of running VACUUM for plain DELETEs as well as HOT updates. The requirement for doing a HOT update is that none of the indexed -columns are changed. This is checked at execution time by comparing the -binary representation of the old and new values. We insist on bitwise -equality rather than using datatype-specific equality routines. The -main reason to avoid the latter is that there might be multiple notions -of equality for a datatype, and we don't know exactly which one is -relevant for the indexes at hand. We assume that bitwise equality -guarantees equality for all purposes. - +columns are changed (with one exception detailed below). This is checked +at execution time by comparing the binary representation of the old and +new values. We insist on bitwise equality rather than using +datatype-specific equality routines. The main reason to avoid the +latter is that there might be multiple notions of equality for a +datatype, and we don't know exactly which one is relevant for the indexes +at hand. We assume that bitwise equality guarantees equality for all +purposes. + +The exception to indexed columns is this: Because HOT is used to retain +referential integrity of indexes across tuple updates, we can still +apply HOT if the changed columns are only indexed by indexes that do not +reference the tuple directly. Indexes which indicate that they summarize +the indexed tuples (at block- or larger granularity, in the amsummarizing +flag of the IndexAmRoutine struct) will therefore not block the HOT +optimization for updates. Note that even if HOT is applied in this case +of only summarized columns getting updated, the updated value still needs +to be propagated to the indexes that contain the updated columns: The +data which the summary is based on has been updated, so the summary must +be updated. This is still more work than the lack of index updates in +normal HOT, but it's much preferred over having to update all indexes. Abort Cases ----------- -- 2.40.1