diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2019-03-22 13:21:20 +0200 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2019-03-22 13:21:45 +0200 |
commit | 7df159a620b760e289f1795b13542ed1b3e13b87 (patch) | |
tree | e4ca41fc59cf7263e32264791617b9ae5a2dca8e /src/backend/access/rmgrdesc/gistdesc.c | |
parent | df816f6ad532ad685a3897869a2e64d3a53fe312 (diff) | |
download | postgresql-7df159a620b760e289f1795b13542ed1b3e13b87.tar.gz postgresql-7df159a620b760e289f1795b13542ed1b3e13b87.zip |
Delete empty pages during GiST VACUUM.
To do this, we scan GiST two times. In the first pass we make note of
empty leaf pages and internal pages. At second pass we scan through
internal pages, looking for downlinks to the empty pages.
Deleting internal pages is still not supported, like in nbtree, the last
child of an internal page is never deleted. That means that if you have a
workload where new keys are always inserted to different area than where
old keys are removed, the index will still grow without bound. But the rate
of growth will be an order of magnitude slower than before.
Author: Andrey Borodin
Discussion: https://www.postgresql.org/message-id/B1E4DF12-6CD3-4706-BDBD-BF3283328F60@yandex-team.ru
Diffstat (limited to 'src/backend/access/rmgrdesc/gistdesc.c')
-rw-r--r-- | src/backend/access/rmgrdesc/gistdesc.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c index e468c9e15aa..3ff4f83d387 100644 --- a/src/backend/access/rmgrdesc/gistdesc.c +++ b/src/backend/access/rmgrdesc/gistdesc.c @@ -24,6 +24,15 @@ out_gistxlogPageUpdate(StringInfo buf, gistxlogPageUpdate *xlrec) } static void +out_gistxlogPageReuse(StringInfo buf, gistxlogPageReuse *xlrec) +{ + appendStringInfo(buf, "rel %u/%u/%u; blk %u; latestRemovedXid %u", + xlrec->node.spcNode, xlrec->node.dbNode, + xlrec->node.relNode, xlrec->block, + xlrec->latestRemovedXid); +} + +static void out_gistxlogDelete(StringInfo buf, gistxlogPageUpdate *xlrec) { } @@ -35,6 +44,13 @@ out_gistxlogPageSplit(StringInfo buf, gistxlogPageSplit *xlrec) xlrec->npage); } +static void +out_gistxlogPageDelete(StringInfo buf, gistxlogPageDelete *xlrec) +{ + appendStringInfo(buf, "deleteXid %u; downlink %u", + xlrec->deleteXid, xlrec->downlinkOffset); +} + void gist_desc(StringInfo buf, XLogReaderState *record) { @@ -46,6 +62,9 @@ gist_desc(StringInfo buf, XLogReaderState *record) case XLOG_GIST_PAGE_UPDATE: out_gistxlogPageUpdate(buf, (gistxlogPageUpdate *) rec); break; + case XLOG_GIST_PAGE_REUSE: + out_gistxlogPageReuse(buf, (gistxlogPageReuse *) rec); + break; case XLOG_GIST_DELETE: out_gistxlogDelete(buf, (gistxlogPageUpdate *) rec); break; @@ -54,6 +73,9 @@ gist_desc(StringInfo buf, XLogReaderState *record) break; case XLOG_GIST_CREATE_INDEX: break; + case XLOG_GIST_PAGE_DELETE: + out_gistxlogPageDelete(buf, (gistxlogPageDelete *) rec); + break; } } @@ -70,12 +92,18 @@ gist_identify(uint8 info) case XLOG_GIST_DELETE: id = "DELETE"; break; + case XLOG_GIST_PAGE_REUSE: + id = "PAGE_REUSE"; + break; case XLOG_GIST_PAGE_SPLIT: id = "PAGE_SPLIT"; break; case XLOG_GIST_CREATE_INDEX: id = "CREATE_INDEX"; break; + case XLOG_GIST_PAGE_DELETE: + id = "PAGE_DELETE"; + break; } return id; |