pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <heikki.linnakangas@iki.fi>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Generate less WAL during GiST, GIN and SP-GiST index build.
Date: Wed, 03 Apr 2019 14:06:49 +0000
Message-ID: <E1hBgXR-0006qi-HK@gemulon.postgresql.org> (raw)

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/9155580fd5fc2a0cbb23376dfca7cd21f59c2c7b

Modified Files
--------------
src/backend/access/gin/ginbtree.c       |  6 +--
src/backend/access/gin/gindatapage.c    |  9 ++--
src/backend/access/gin/ginentrypage.c   |  2 +-
src/backend/access/gin/gininsert.c      | 31 ++++++-------
src/backend/access/gin/ginutil.c        |  4 +-
src/backend/access/gin/ginvacuum.c      |  2 +-
src/backend/access/gin/ginxlog.c        | 33 -------------
src/backend/access/gist/gist.c          | 76 ++++++++++++++++++------------
src/backend/access/gist/gistbuild.c     | 29 ++++++------
src/backend/access/gist/gistutil.c      |  2 +-
src/backend/access/gist/gistxlog.c      | 22 ---------
src/backend/access/rmgrdesc/gindesc.c   |  6 ---
src/backend/access/rmgrdesc/gistdesc.c  |  5 --
src/backend/access/rmgrdesc/spgdesc.c   |  5 --
src/backend/access/spgist/spgdoinsert.c | 12 ++---
src/backend/access/spgist/spginsert.c   | 31 +++++--------
src/backend/access/spgist/spgxlog.c     | 35 --------------
src/backend/access/transam/xlog.c       | 20 ++++----
src/backend/access/transam/xloginsert.c | 82 +++++++++++++++++++++++++++++++++
src/include/access/gin.h                |  3 +-
src/include/access/ginxlog.h            |  2 -
src/include/access/gist.h               |  7 +++
src/include/access/gist_private.h       |  7 ++-
src/include/access/gistxlog.h           |  2 +-
src/include/access/spgxlog.h            |  2 +-
src/include/access/xlogdefs.h           |  7 +++
src/include/access/xloginsert.h         |  3 ++
27 files changed, 223 insertions(+), 222 deletions(-)



Message-ID: <E1hBgXR-0006qi-HK@gemulon.postgresql.org>
Permalink:  ../E1hBgXR-0006qi-HK@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1hBgXR-0006qi-HK@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: heikki.linnakangas@iki.fi
  Subject: Re: pgsql: Generate less WAL during GiST, GIN and SP-GiST index build.
  In-Reply-To: <E1hBgXR-0006qi-HK@gemulon.postgresql.org>
  References: <E1hBgXR-0006qi-HK@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox