diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2014-03-31 15:15:19 +0300 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2014-03-31 15:23:50 +0300 |
commit | 14d02f0bb352d70d50106e153aca4af9c4b0b842 (patch) | |
tree | 695633a4ebbb4b50da88b43d5cb5a1283018b32f /src/include/access/gin_private.h | |
parent | 0cfa34c25a7c8e7017cac346d954016fad0dfc16 (diff) | |
download | postgresql-14d02f0bb352d70d50106e153aca4af9c4b0b842.tar.gz postgresql-14d02f0bb352d70d50106e153aca4af9c4b0b842.zip |
Rewrite the way GIN posting lists are packed on a page, to reduce WAL volume.
Inserting (in retail) into the new 9.4 format GIN posting tree created much
larger WAL records than in 9.3. The previous strategy to WAL logging was
basically to log the whole page on each change, with the exception of
completely unmodified segments up to the first modified one. That was not
too bad when appending to the end of the page, as only the last segment had
to be WAL-logged, but per Fujii Masao's testing, even that produced 2x the
WAL volume that 9.3 did.
The new strategy is to keep track of changes to the posting lists in a more
fine-grained fashion, and also make the repacking" code smarter to avoid
decoding and re-encoding segments unnecessarily.
Diffstat (limited to 'src/include/access/gin_private.h')
-rw-r--r-- | src/include/access/gin_private.h | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/src/include/access/gin_private.h b/src/include/access/gin_private.h index d11811acb57..d33c216b757 100644 --- a/src/include/access/gin_private.h +++ b/src/include/access/gin_private.h @@ -406,7 +406,8 @@ typedef struct * whose split this insertion finishes. As BlockIdData[2] (beware of adding * fields before this that would make them not 16-bit aligned) * - * 2. one of the following structs, depending on tree type. + * 2. an ginxlogInsertEntry or ginxlogRecompressDataLeaf struct, depending + * on tree type. * * NB: the below structs are only 16-bit aligned when appended to a * ginxlogInsert struct! Beware of adding fields to them that require @@ -421,15 +422,39 @@ typedef struct IndexTupleData tuple; /* variable length */ } ginxlogInsertEntry; + typedef struct { - uint16 length; - uint16 unmodifiedsize; + uint16 nactions; - /* compressed segments, variable length */ - char newdata[1]; + /* Variable number of 'actions' follow */ } ginxlogRecompressDataLeaf; +/* + * Note: this struct is currently not used in code, and only acts as + * documentation. The WAL record format is as specified here, but the code + * uses straight access through a Pointer and memcpy to read/write these. + */ +typedef struct +{ + uint8 segno; /* segment this action applies to */ + char type; /* action type (see below) */ + + /* + * Action-specific data follows. For INSERT and REPLACE actions that is a + * GinPostingList struct. For ADDITEMS, a uint16 for the number of items + * added, followed by the items themselves as ItemPointers. DELETE actions + * have no further data. + */ +} ginxlogSegmentAction; + +/* Action types */ +#define GIN_SEGMENT_UNMODIFIED 0 /* no action (not used in WAL records) */ +#define GIN_SEGMENT_DELETE 1 /* a whole segment is removed */ +#define GIN_SEGMENT_INSERT 2 /* a whole segment is added */ +#define GIN_SEGMENT_REPLACE 3 /* a segment is replaced */ +#define GIN_SEGMENT_ADDITEMS 4 /* items are added to existing segment */ + typedef struct { OffsetNumber offset; |