agora inbox for pgsql-hackers@postgresql.org
help / color / mirror / Atom feedFrom: Nathan Bossart <nathandbossart@gmail.com>
To: Sehrope Sarkuni <sehrope@jackdb.com>
Cc: Pg Hackers <pgsql-hackers@postgresql.org>
Subject: Re: Speed up lpad() and rpad() for one-byte padding strings
Date: Wed, 23 Sep 2026 09:41:36 -0500
Message-ID: <arPlICNzFXv6zTbS@nathan> (raw)
In-Reply-To: <CAH7T-apj+pFg9bRkXVGfGejS2Uu4WzdMd7KoLKTW11mdsrt1Ew@mail.gmail.com>
References: <CAH7T-apj+pFg9bRkXVGfGejS2Uu4WzdMd7KoLKTW11mdsrt1Ew@mail.gmail.com>
On Wed, Sep 23, 2026 at 10:10:09AM -0400, Sehrope Sarkuni wrote:
> lpad() and rpad() pad one character at a time, calling
> pg_mblen_range() and memcpy() once per padding char. When the padding
> string is a single byte, e.g., lpad(x, n, '0') or rpad(x, n, ' '),
> the padding is that byte repeated, so the attached patch fills it with
> one memset().
I wonder if we could expand these gains by using SIMD whenever the vector
length is divisible by the padding string length. My hunch is that's where
a lot of the memset() gains come from.
--
nathan
view thread (7+ messages) latest in thread
Message-ID: <arPlICNzFXv6zTbS@nathan>
Permalink: ../arPlICNzFXv6zTbS@nathan/
Also on: postgresql.org/message-id/arPlICNzFXv6zTbS@nathan
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-hackers@postgresql.org
Cc: nathandbossart@gmail.com, sehrope@jackdb.com
Subject: Re: Speed up lpad() and rpad() for one-byte padding strings
In-Reply-To: <arPlICNzFXv6zTbS@nathan>
* 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