diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2011-04-19 18:51:08 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2011-04-19 18:51:08 -0400 |
commit | 5a4305fdf7ecf8218051f4f2a151d57fa71b9e6b (patch) | |
tree | 8841f188f0a4a4e6fac6f85da8cb16ebad175cf4 /src/backend/commands/cluster.c | |
parent | 1f0ad40656fc0cca935cd20038064e6281a55d30 (diff) | |
download | postgresql-5a4305fdf7ecf8218051f4f2a151d57fa71b9e6b.tar.gz postgresql-5a4305fdf7ecf8218051f4f2a151d57fa71b9e6b.zip |
Avoid changing an index's indcheckxmin horizon during REINDEX.
There can never be a need to push the indcheckxmin horizon forward, since
any HOT chains that are actually broken with respect to the index must
pre-date its original creation. So we can just avoid changing pg_index
altogether during a REINDEX operation.
This offers a cleaner solution than my previous patch for the problem
found a few days ago that we mustn't try to update pg_index while we are
reindexing it. System catalog indexes will always be created with
indcheckxmin = false during initdb, and with this modified code we should
never try to change their pg_index entries. This avoids special-casing
system catalogs as the former patch did, and should provide a performance
benefit for many cases where REINDEX formerly caused an index to be
considered unusable for a short time.
Back-patch to 8.3 to cover all versions containing HOT. Note that this
patch changes the API for index_build(), but I believe it is unlikely that
any add-on code is calling that directly.
Diffstat (limited to 'src/backend/commands/cluster.c')
-rw-r--r-- | src/backend/commands/cluster.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c index 816cf47bb3d..f6dc6e2c017 100644 --- a/src/backend/commands/cluster.c +++ b/src/backend/commands/cluster.c @@ -626,6 +626,12 @@ rebuild_relation(Relation OldHeap, Oid indexOid) * Rebuild each index on the relation (but not the toast table, which is * all-new at this point). We do not need CommandCounterIncrement() * because reindex_relation does it. + * + * Note: because index_build is called via reindex_relation, it will never + * set indcheckxmin true for the indexes. This is OK even though in some + * sense we are building new indexes rather than rebuilding existing ones, + * because the new heap won't contain any HOT chains at all, let alone + * broken ones, so it can't be necessary to set indcheckxmin. */ reindex_relation(tableOid, false); |