pgsql: Avoid CREATE INDEX unique index deduplication.

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Avoid CREATE INDEX unique index deduplication.
Date: 2020-07-17 16:51:37
Message-ID: E1jwTaD-0005N4-3A@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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.

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/5da8bf8bbb5c119d4bd767dbdfaf10efd348c0fd

Modified Files
--------------
src/backend/access/nbtree/nbtsort.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2020-07-17 17:04:20 pgsql: Cope with data-offset-less archive files during out-of-order res
Previous Message Tom Lane 2020-07-17 15:05:32 pgsql: Ensure that distributed timezone abbreviation files are plain AS