Specialize tuplesort routines for different kinds of abbreviated keys
authorJohn Naylor <john.naylor@postgresql.org>
Sat, 2 Apr 2022 08:22:25 +0000 (15:22 +0700)
committerJohn Naylor <john.naylor@postgresql.org>
Sat, 2 Apr 2022 08:22:25 +0000 (15:22 +0700)
commit6974924347c908335607a4a2f252213d58e21b7c
treeaa8d5fa5f4aba89f846957410dc0176556180397
parentdb086de5abe5d87b07cddd030092b1f81f99c5ea
Specialize tuplesort routines for different kinds of abbreviated keys

Previously, the specialized tuplesort routine inlined handling for
reverse-sort and NULLs-ordering but called the datum comparator via a
pointer in the SortSupport struct parameter. Testing has showed that we
can get a useful performance gain by specializing datum comparison for
the different representations of abbreviated keys -- signed and unsigned
64-bit integers and signed 32-bit integers. Almost all abbreviatable data
types will benefit -- the only exception for now is numeric, since the
datum comparison is more complex. The performance gain depends on data
type and input distribution, but often falls in the range of 10-20% faster.

Thomas Munro

Reviewed by Peter Geoghegan, review and performance testing by me

Discussion:
https://www.postgresql.org/message-id/CA%2BhUKGKKYttZZk-JMRQSVak%3DCXSJ5fiwtirFf%3Dn%3DPAbumvn1Ww%40mail.gmail.com
src/backend/access/gist/gistproc.c
src/backend/access/nbtree/nbtcompare.c
src/backend/utils/adt/date.c
src/backend/utils/adt/mac.c
src/backend/utils/adt/network.c
src/backend/utils/adt/timestamp.c
src/backend/utils/adt/uuid.c
src/backend/utils/adt/varlena.c
src/backend/utils/sort/tuplesort.c
src/include/utils/sortsupport.h