summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorPeter Geoghegan2020-01-03 20:18:13 +0000
committerPeter Geoghegan2020-01-03 20:18:13 +0000
commitd2e5e20e57111cca9e14f6e5a99a186d4c66a5b7 (patch)
tree3eb23c2ed6433a48866dac0ecf4cad4b6b7cbfea /src/include
parent56a3921a2f5102f804bd0ff741e144a0e6f1c0b6 (diff)
Add xl_btree_delete optimization.
Commit 558a9165e08 taught _bt_delitems_delete() to produce its own XID horizon on the primary. Standbys no longer needed to generate their own latestRemovedXid, since they could just use the explicitly logged value from the primary instead. The deleted offset numbers array from the xl_btree_delete WAL record was no longer used by the REDO routine for anything other than deleting the items. This enables a minor optimization: We now treat the array as buffer state, not generic WAL data, following _bt_delitems_vacuum()'s example. This should be a minor win, since it allows us to avoid including the deleted items array in cases where XLogInsert() stores the whole buffer anyway. The primary goal here is to make the code more maintainable, though. Removing inessential differences between the two functions highlights the fundamental differences that remain. Also change xl_btree_delete to use uint32 for the size of the array of item offsets being deleted. This brings xl_btree_delete closer to xl_btree_vacuum. Furthermore, it seems like a good idea to use an explicit-width integer type (the field was previously an "int"). Bump XLOG_PAGE_MAGIC because xl_btree_delete changed. Discussion: https://postgr.es/m/CAH2-Wzkz4TjmezzfAbaV1zYrh=fr0bCpzuJTvBe5iUQ3aUPsCQ@mail.gmail.com
Diffstat (limited to 'src/include')
-rw-r--r--src/include/access/nbtree.h3
-rw-r--r--src/include/access/nbtxlog.h6
-rw-r--r--src/include/access/xlog_internal.h2
3 files changed, 6 insertions, 5 deletions
diff --git a/src/include/access/nbtree.h b/src/include/access/nbtree.h
index 4f84ca83dc4..f90ee3a0e00 100644
--- a/src/include/access/nbtree.h
+++ b/src/include/access/nbtree.h
@@ -779,7 +779,8 @@ extern bool _bt_page_recyclable(Page page);
extern void _bt_delitems_vacuum(Relation rel, Buffer buf,
OffsetNumber *deletable, int ndeletable);
extern void _bt_delitems_delete(Relation rel, Buffer buf,
- OffsetNumber *itemnos, int nitems, Relation heapRel);
+ OffsetNumber *deletable, int ndeletable,
+ Relation heapRel);
extern int _bt_pagedel(Relation rel, Buffer buf);
/*
diff --git a/src/include/access/nbtxlog.h b/src/include/access/nbtxlog.h
index 3da55146555..776a9bd7233 100644
--- a/src/include/access/nbtxlog.h
+++ b/src/include/access/nbtxlog.h
@@ -126,12 +126,12 @@ typedef struct xl_btree_split
typedef struct xl_btree_delete
{
TransactionId latestRemovedXid;
- int nitems;
+ uint32 ndeleted;
- /* TARGET OFFSET NUMBERS FOLLOW AT THE END */
+ /* DELETED TARGET OFFSET NUMBERS FOLLOW */
} xl_btree_delete;
-#define SizeOfBtreeDelete (offsetof(xl_btree_delete, nitems) + sizeof(int))
+#define SizeOfBtreeDelete (offsetof(xl_btree_delete, ndeleted) + sizeof(uint32))
/*
* This is what we need to know about page reuse within btree. This record
diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h
index 0a836d1c928..087918d41dd 100644
--- a/src/include/access/xlog_internal.h
+++ b/src/include/access/xlog_internal.h
@@ -31,7 +31,7 @@
/*
* Each page of XLOG file has a header like this:
*/
-#define XLOG_PAGE_MAGIC 0xD103 /* can be used as WAL version indicator */
+#define XLOG_PAGE_MAGIC 0xD104 /* can be used as WAL version indicator */
typedef struct XLogPageHeaderData
{