summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorHeikki Linnakangas2014-03-12 20:46:04 +0000
committerHeikki Linnakangas2014-03-12 21:28:36 +0000
commita3115f0d9ec1ac93b82156535dc00b10172a4fe7 (patch)
tree675870269d119e1632d9345539efd11ac16d044e /src/include
parent17d787a3b160eefb2ff4a3fdf12ca1fedc02cbc1 (diff)
Only WAL-log the modified portion in an UPDATE, if possible.
When a row is updated, and the new tuple version is put on the same page as the old one, only WAL-log the part of the new tuple that's not identical to the old. This saves significantly on the amount of WAL that needs to be written, in the common case that most fields are not modified. Amit Kapila, with a lot of back and forth with me, Robert Haas, and others.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/access/heapam_xlog.h19
-rw-r--r--src/include/access/xlog.h1
2 files changed, 19 insertions, 1 deletions
diff --git a/src/include/access/heapam_xlog.h b/src/include/access/heapam_xlog.h
index 194635952cb..d6bc8f7f24f 100644
--- a/src/include/access/heapam_xlog.h
+++ b/src/include/access/heapam_xlog.h
@@ -67,6 +67,8 @@
#define XLOG_HEAP_CONTAINS_OLD_TUPLE (1<<2)
#define XLOG_HEAP_CONTAINS_OLD_KEY (1<<3)
#define XLOG_HEAP_CONTAINS_NEW_TUPLE (1<<4)
+#define XLOG_HEAP_PREFIX_FROM_OLD (1<<5)
+#define XLOG_HEAP_SUFFIX_FROM_OLD (1<<6)
/* convenience macro for checking whether any form of old tuple was logged */
#define XLOG_HEAP_CONTAINS_OLD \
@@ -179,7 +181,22 @@ typedef struct xl_heap_update
ItemPointerData newtid; /* new inserted tuple id */
uint8 old_infobits_set; /* infomask bits to set on old tuple */
uint8 flags;
- /* NEW TUPLE xl_heap_header AND TUPLE DATA FOLLOWS AT END OF STRUCT */
+
+ /*
+ * If XLOG_HEAP_PREFIX_FROM_OLD or XLOG_HEAP_SUFFIX_FROM_OLD flags are
+ * set, the prefix and/or suffix come next, as one or two uint16s.
+ *
+ * After that, xl_heap_header_len and new tuple data follow. The new
+ * tuple data and length don't include the prefix and suffix, which are
+ * copied from the old tuple on replay. The new tuple data is omitted if
+ * a full-page image of the page was taken (unless the
+ * XLOG_HEAP_CONTAINS_NEW_TUPLE flag is set, in which case it's included
+ * anyway).
+ *
+ * If XLOG_HEAP_CONTAINS_OLD_TUPLE or XLOG_HEAP_CONTAINS_OLD_KEY flags are
+ * set, another xl_heap_header_len struct and tuple data for the old tuple
+ * follows.
+ */
} xl_heap_update;
#define SizeOfHeapUpdate (offsetof(xl_heap_update, flags) + sizeof(uint8))
diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h
index a238292b76e..35092284664 100644
--- a/src/include/access/xlog.h
+++ b/src/include/access/xlog.h
@@ -279,6 +279,7 @@ typedef struct CheckpointStatsData
extern CheckpointStatsData CheckpointStats;
extern XLogRecPtr XLogInsert(RmgrId rmid, uint8 info, XLogRecData *rdata);
+extern bool XLogCheckBufferNeedsBackup(Buffer buffer);
extern void XLogFlush(XLogRecPtr RecPtr);
extern bool XLogBackgroundFlush(void);
extern bool XLogNeedsFlush(XLogRecPtr RecPtr);