agora inbox for pgsql-committers@postgresql.org
help / color / mirror / Atom feedFrom: Masahiko Sawada <msawada@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Use hex_decode_safe() to speed up UUID input.
Date: Tue, 15 Sep 2026 22:07:43 +0000
Message-ID: <E1x6bJX-00000000UqH-1lvi@gemulon.postgresql.org> (raw)
Use hex_decode_safe() to speed up UUID input.
Previously, string_to_uuid() decoded one byte at a time, calling
isxdigit() twice and strtoul() once for every pair of hexadecimal
digits. Commit ec8719ccbfcd made hex_decode_safe() decode a run of
hexadecimal digits in bulk, so add a fast path for the two common
shapes: 32 contiguous hexadecimal digits, and the canonical
8x-4x-4x-4x-12x form, each optionally wrapped in braces.
Anything else, and any decoding error, falls back to the
byte-at-a-time parser, so the accepted grammar and the error messages
don't change. hex_decode_safe() also skips whitespace, which the UUID
grammar forbids, so we treat a short decode as an error too. Rejecting
an input that has a fast-path shape therefore costs a second
parse. But this only happens for syntax-error cases, so it's not a
problem in practice.
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Reviewed-by: Haibo Yan <tristan.yim@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: John Naylor <johncnaylorls@gmail.com>
Discussion: https://postgr.es/m/CAD21AoCqeR4UQU77Q_yOMNNzJ7AVeiO5QZT+4HnzPm4Wm-e02Q@mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/72af14bccd2127bf20ddeaf198b78de46e9e892b
Modified Files
--------------
src/backend/utils/adt/uuid.c | 101 +++++++++++++++++++++++++++++++++++--
src/test/regress/expected/uuid.out | 74 +++++++++++++++++++++++++++
src/test/regress/sql/uuid.sql | 24 +++++++++
3 files changed, 194 insertions(+), 5 deletions(-)
Message-ID: <E1x6bJX-00000000UqH-1lvi@gemulon.postgresql.org>
Permalink: ../E1x6bJX-00000000UqH-1lvi@gemulon.postgresql.org/
Also on: postgresql.org/message-id/E1x6bJX-00000000UqH-1lvi@gemulon.postgresql.org
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-committers@postgresql.org
Cc: msawada@postgresql.org, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Use hex_decode_safe() to speed up UUID input.
In-Reply-To: <E1x6bJX-00000000UqH-1lvi@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox