Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 1a6f5a0

Browse files
Go back to considering HOT on pages marked full.
Commit 2fd8685 simplified the checking of modified attributes that takes place within heap_update(). This included a micro-optimization affecting pages marked PD_PAGE_FULL: don't even try to use HOT to save a few cycles on determining HOT safety. The assumption was that it won't work out this time around, since it can't have worked out last time around. Remove the micro-optimization. It could only ever save cycles that are consumed by the vast majority of heap_update() calls, which hardly seems worth the added complexity. It also seems quite possible that there are workloads that will do worse over time by repeated application of the micro-optimization, despite saving some cycles on average, in the short term. Author: Peter Geoghegan <pg@bowt.ie> Reviewed-By: Álvaro Herrera <alvherre@alvh.no-ip.org> Discussion: https://postgr.es/m/CAH2-WznU1L3+DMPr1F7o2eJBT7=3bAJoY6ZkWABAxNt+-afyTA@mail.gmail.com
1 parent dd484c9 commit 1a6f5a0

File tree

1 file changed

+6
-25
lines changed

1 file changed

+6
-25
lines changed

src/backend/access/heap/heapam.c

+6-25
Original file line numberDiff line numberDiff line change
@@ -3179,7 +3179,6 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
31793179
bool have_tuple_lock = false;
31803180
bool iscombo;
31813181
bool use_hot_update = false;
3182-
bool hot_attrs_checked = false;
31833182
bool key_intact;
31843183
bool all_visible_cleared = false;
31853184
bool all_visible_cleared_new = false;
@@ -3228,32 +3227,15 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
32283227
key_attrs = RelationGetIndexAttrBitmap(relation, INDEX_ATTR_BITMAP_KEY);
32293228
id_attrs = RelationGetIndexAttrBitmap(relation,
32303229
INDEX_ATTR_BITMAP_IDENTITY_KEY);
3231-
3230+
interesting_attrs = NULL;
3231+
interesting_attrs = bms_add_members(interesting_attrs, hot_attrs);
3232+
interesting_attrs = bms_add_members(interesting_attrs, key_attrs);
3233+
interesting_attrs = bms_add_members(interesting_attrs, id_attrs);
32323234

32333235
block = ItemPointerGetBlockNumber(otid);
32343236
buffer = ReadBuffer(relation, block);
32353237
page = BufferGetPage(buffer);
32363238

3237-
interesting_attrs = NULL;
3238-
3239-
/*
3240-
* If the page is already full, there is hardly any chance of doing a HOT
3241-
* update on this page. It might be wasteful effort to look for index
3242-
* column updates only to later reject HOT updates for lack of space in
3243-
* the same page. So we be conservative and only fetch hot_attrs if the
3244-
* page is not already full. Since we are already holding a pin on the
3245-
* buffer, there is no chance that the buffer can get cleaned up
3246-
* concurrently and even if that was possible, in the worst case we lose a
3247-
* chance to do a HOT update.
3248-
*/
3249-
if (!PageIsFull(page))
3250-
{
3251-
interesting_attrs = bms_add_members(interesting_attrs, hot_attrs);
3252-
hot_attrs_checked = true;
3253-
}
3254-
interesting_attrs = bms_add_members(interesting_attrs, key_attrs);
3255-
interesting_attrs = bms_add_members(interesting_attrs, id_attrs);
3256-
32573239
/*
32583240
* Before locking the buffer, pin the visibility map page if it appears to
32593241
* be necessary. Since we haven't got the lock yet, someone else might be
@@ -3867,10 +3849,9 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
38673849
/*
38683850
* Since the new tuple is going into the same page, we might be able
38693851
* to do a HOT update. Check if any of the index columns have been
3870-
* changed. If the page was already full, we may have skipped checking
3871-
* for index columns, and also can't do a HOT update.
3852+
* changed.
38723853
*/
3873-
if (hot_attrs_checked && !bms_overlap(modified_attrs, hot_attrs))
3854+
if (!bms_overlap(modified_attrs, hot_attrs))
38743855
use_hot_update = true;
38753856
}
38763857
else

0 commit comments

Comments
 (0)