diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2014-03-12 22:46:04 +0200 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2014-03-12 23:28:36 +0200 |
commit | a3115f0d9ec1ac93b82156535dc00b10172a4fe7 (patch) | |
tree | 675870269d119e1632d9345539efd11ac16d044e /src/include/access/heapam_xlog.h | |
parent | 17d787a3b160eefb2ff4a3fdf12ca1fedc02cbc1 (diff) | |
download | postgresql-a3115f0d9ec1ac93b82156535dc00b10172a4fe7.tar.gz postgresql-a3115f0d9ec1ac93b82156535dc00b10172a4fe7.zip |
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/access/heapam_xlog.h')
-rw-r--r-- | src/include/access/heapam_xlog.h | 19 |
1 files changed, 18 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)) |