diff options
author | John Naylor <john.naylor@postgresql.org> | 2022-04-02 15:22:25 +0700 |
---|---|---|
committer | John Naylor <john.naylor@postgresql.org> | 2022-04-02 15:22:25 +0700 |
commit | 6974924347c908335607a4a2f252213d58e21b7c (patch) | |
tree | aa8d5fa5f4aba89f846957410dc0176556180397 /src/backend/utils/adt/network.c | |
parent | db086de5abe5d87b07cddd030092b1f81f99c5ea (diff) | |
download | postgresql-6974924347c908335607a4a2f252213d58e21b7c.tar.gz postgresql-6974924347c908335607a4a2f252213d58e21b7c.zip |
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
Diffstat (limited to 'src/backend/utils/adt/network.c')
-rw-r--r-- | src/backend/utils/adt/network.c | 17 |
1 files changed, 1 insertions, 16 deletions
diff --git a/src/backend/utils/adt/network.c b/src/backend/utils/adt/network.c index 0ab54316f8e..ea1c7390d0d 100644 --- a/src/backend/utils/adt/network.c +++ b/src/backend/utils/adt/network.c @@ -53,7 +53,6 @@ typedef struct static int32 network_cmp_internal(inet *a1, inet *a2); static int network_fast_cmp(Datum x, Datum y, SortSupport ssup); -static int network_cmp_abbrev(Datum x, Datum y, SortSupport ssup); static bool network_abbrev_abort(int memtupcount, SortSupport ssup); static Datum network_abbrev_convert(Datum original, SortSupport ssup); static List *match_network_function(Node *leftop, @@ -456,7 +455,7 @@ network_sortsupport(PG_FUNCTION_ARGS) ssup->ssup_extra = uss; - ssup->comparator = network_cmp_abbrev; + ssup->comparator = ssup_datum_unsigned_cmp; ssup->abbrev_converter = network_abbrev_convert; ssup->abbrev_abort = network_abbrev_abort; ssup->abbrev_full_comparator = network_fast_cmp; @@ -480,20 +479,6 @@ network_fast_cmp(Datum x, Datum y, SortSupport ssup) } /* - * Abbreviated key comparison func - */ -static int -network_cmp_abbrev(Datum x, Datum y, SortSupport ssup) -{ - if (x > y) - return 1; - else if (x == y) - return 0; - else - return -1; -} - -/* * Callback for estimating effectiveness of abbreviated key optimization. * * We pay no attention to the cardinality of the non-abbreviated data, because |