Re: A qsort template - Mailing list pgsql-hackers

From Peter Geoghegan
Subject Re: A qsort template
Date
Msg-id CAH2-Wz==X6rxnFNBn2yH=xmNdCAvQxFMnDdMoTgn2V5guQEB-A@mail.gmail.com
Whole thread Raw
In response to Re: A qsort template  (Thomas Munro <thomas.munro@gmail.com>)
Responses Re: A qsort template
List pgsql-hackers
On Sun, Apr 10, 2022 at 2:44 PM Thomas Munro <thomas.munro@gmail.com> wrote:
> David Rowley privately reported a performance regression when sorting
> single ints with a lot of duplicates, in a case that previously hit
> qsort_ssup() but now hits qsort_tuple_int32() and then has to call the
> tiebreaker comparator.

That's not good.

The B&M quicksort implementation that we adopted is generally
extremely fast for that case, since it uses 3 way partitioning (based
on the Dutch National Flag algorithm). This essentially makes sorting
large groups of duplicates take only linear time (not linearithmic
time).

-- 
Peter Geoghegan



pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: Improving btree performance through specializing by key shape, take 2
Next
From: Peter Geoghegan
Date:
Subject: Re: Improving btree performance through specializing by key shape, take 2