]> granicus.if.org Git - postgresql/commit
Generate less WAL during GiST, GIN and SP-GiST index build.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Wed, 3 Apr 2019 14:03:15 +0000 (17:03 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Wed, 3 Apr 2019 14:03:15 +0000 (17:03 +0300)
commit9155580fd5fc2a0cbb23376dfca7cd21f59c2c7b
tree558d93b3353b07da171723e9207b68c24f163330
parent5f768045a1a25847a3eea59d309e28c8141aed44
Generate less WAL during GiST, GIN and SP-GiST index build.

Instead of WAL-logging every modification during the build separately,
first build the index without any WAL-logging, and make a separate pass
through the index at the end, to write all pages to the WAL. This
significantly reduces the amount of WAL generated, and is usually also
faster, despite the extra I/O needed for the extra scan through the index.
WAL generated this way is also faster to replay.

For GiST, the LSN-NSN interlock makes this a little tricky. All pages must
be marked with a valid (i.e. non-zero) LSN, so that the parent-child
LSN-NSN interlock works correctly. We now use magic value 1 for that during
index build. Change the fake LSN counter to begin from 1000, so that 1 is
safely smaller than any real or fake LSN. 2 would've been enough for our
purposes, but let's reserve a bigger range, in case we need more special
values in the future.

Author: Anastasia Lubennikova, Andrey V. Lepikhov
Reviewed-by: Heikki Linnakangas, Dmitry Dolgov
27 files changed:
src/backend/access/gin/ginbtree.c
src/backend/access/gin/gindatapage.c
src/backend/access/gin/ginentrypage.c
src/backend/access/gin/gininsert.c
src/backend/access/gin/ginutil.c
src/backend/access/gin/ginvacuum.c
src/backend/access/gin/ginxlog.c
src/backend/access/gist/gist.c
src/backend/access/gist/gistbuild.c
src/backend/access/gist/gistutil.c
src/backend/access/gist/gistxlog.c
src/backend/access/rmgrdesc/gindesc.c
src/backend/access/rmgrdesc/gistdesc.c
src/backend/access/rmgrdesc/spgdesc.c
src/backend/access/spgist/spgdoinsert.c
src/backend/access/spgist/spginsert.c
src/backend/access/spgist/spgxlog.c
src/backend/access/transam/xlog.c
src/backend/access/transam/xloginsert.c
src/include/access/gin.h
src/include/access/ginxlog.h
src/include/access/gist.h
src/include/access/gist_private.h
src/include/access/gistxlog.h
src/include/access/spgxlog.h
src/include/access/xlogdefs.h
src/include/access/xloginsert.h