summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Geoghegan <pg@bowt.ie>2020-07-17 09:50:48 -0700
committerPeter Geoghegan <pg@bowt.ie>2020-07-17 09:50:48 -0700
commit5da8bf8bbb5c119d4bd767dbdfaf10efd348c0fd (patch)
tree428f229ef7b461ca58f5bdef407fc8f572275ea6
parent7fe3083f4cc9cb213f99deecf1bf775a9270b3b2 (diff)
downloadpostgresql-5da8bf8bbb5c119d4bd767dbdfaf10efd348c0fd.tar.gz
Avoid CREATE INDEX unique index deduplication.
There is no advantage to attempting deduplication for a unique index during CREATE INDEX, since there cannot possibly be any duplicates. Doing so wastes cycles due to unnecessary copying. Make sure that we avoid it consistently. We already avoided unique index deduplication in the case where there were some spool2 tuples to merge. That didn't account for the fact that spool2 is removed early/unset in the common case where it has no tuples that need to be merged (i.e. it failed to account for the "spool2 turns out to be unnecessary" optimization in _bt_spools_heapscan()). Oversight in commit 0d861bbb, which added nbtree deduplication Backpatch: 13-, where nbtree deduplication was introduced.
-rw-r--r--src/backend/access/nbtree/nbtsort.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/backend/access/nbtree/nbtsort.c b/src/backend/access/nbtree/nbtsort.c
index e6b7211136..efee86784b 100644
--- a/src/backend/access/nbtree/nbtsort.c
+++ b/src/backend/access/nbtree/nbtsort.c
@@ -1192,7 +1192,7 @@ _bt_load(BTWriteState *wstate, BTSpool *btspool, BTSpool *btspool2)
int64 tuples_done = 0;
bool deduplicate;
- deduplicate = wstate->inskey->allequalimage &&
+ deduplicate = wstate->inskey->allequalimage && !btspool->isunique &&
BTGetDeduplicateItems(wstate->index);
if (merge)