pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Rowley <drowley@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Speedup pg_strtok() with a static lookup table
Date: Thu, 26 Nov 2026 04:56:03 +0000
Message-ID: <E1xWRWd-00000000LoE-1eOp@gemulon.postgresql.org> (raw)

Speedup pg_strtok() with a static lookup table

This function has been known to be slow for a while and a redesign is
probably on the cards.  Meanwhile, let's try to squeeze a little more
performance out of it.

Here we define a 256-byte lookup table to specify character classes and
use that in the function rather than writing long and complex
expressions to get the same thing.

A benchmark showed pg_upgrade performing about 5% faster with this
change when restoring the database schemas into the new cluster, so more
of an evolution than a revolution.

Author: David Rowley <dgrowleyml@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: David Steele <david@pgbackrest.org>
Discussion: https://postgr.es/m/CAApHDvo-YKLqfHfjrCFJCBxMXni83Xsfn6Nbe79CWspCHKta_Q@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/56227fd51c452624b1c08947e4ed910a8d78748e

Modified Files
--------------
src/backend/nodes/read.c | 29 +++++++++++++++++++++--------
1 file changed, 21 insertions(+), 8 deletions(-)



Message-ID: <E1xWRWd-00000000LoE-1eOp@gemulon.postgresql.org>
Permalink:  ../E1xWRWd-00000000LoE-1eOp@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xWRWd-00000000LoE-1eOp@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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: drowley@postgresql.org
  Subject: Re: pgsql: Speedup pg_strtok() with a static lookup table
  In-Reply-To: <E1xWRWd-00000000LoE-1eOp@gemulon.postgresql.org>
  References: <E1xWRWd-00000000LoE-1eOp@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 DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox