Re: Pathological performance when inserting many NULLs into a unique index

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Pathological performance when inserting many NULLs into a unique index
Date: 2019-04-20 01:34:29
Message-ID: CAH2-WzkR50K1V7MVFVckAoFi2xwR4TtaicefxCgcHys98yMqtA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Apr 18, 2019 at 8:13 PM Peter Geoghegan <pg(at)bowt(dot)ie> wrote:
> It just occurred to me that the final patch will need to be more
> careful about non-key attributes in INCLUDE indexes. It's not okay for
> it to avoid calling _bt_check_unique() just because a non-key
> attribute was NULL. It should only do that when a key attribute is
> NULL.

Attached revision does it that way, specifically by adding a new field
to the insertion scankey struct (BTScanInsertData). The field is
filled-in when initializing an insertion scankey in the usual way. I
was able to reuse alignment padding for the new field, so there is no
additional space overhead on Linux x86-64.

This is a bit more complicated than v1, but there is still an overall
net reduction in overall complexity (and in LOC). I'm going to commit
this early next week, barring any objections, and assuming I don't
think of any more problems between now and then.
--
Peter Geoghegan

Attachment Content-Type Size
v2-0001-Prevent-O-N-2-unique-index-insertion-edge-case.patch application/octet-stream 12.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2019-04-20 04:05:35 Re: block-level incremental backup
Previous Message Stephen Frost 2019-04-20 01:25:14 Re: [PATCH v20] GSSAPI encryption support