Re: Speed up lpad() and rpad() for one-byte padding strings - Mailing list pgsql-hackers

From John Naylor
Subject Re: Speed up lpad() and rpad() for one-byte padding strings
Date
Msg-id CANWCAZaB8NsQJrKc-pxRTj_=C8CBOTDEWkPW0Eur=ymUSbUwZQ@mail.gmail.com
Whole thread
In response to Speed up lpad() and rpad() for one-byte padding strings  (Sehrope Sarkuni <sehrope@jackdb.com>)
Responses Re: Speed up lpad() and rpad() for one-byte padding strings
List pgsql-hackers
On Wed, Sep 23, 2026 at 9:10 PM Sehrope Sarkuni <sehrope@jackdb.com> wrote:
> Timings on an AMD Ryzen 7 5700G, release build (-O3, no asserts),
> pgbench -c 1 with one statement per transaction, alternating
> before/after rounds, median latency in ms of 5 rounds (3 at 100M):
>
>   SELECT octet_length(rpad('x', N, ' '))
>     or
>   SELECT octet_length(lpad('x', N, '0'))
>
>   N              rpad before   after     lpad before   after
>   1                  0.056     0.056         0.057     0.056
>   10                 0.056     0.056         0.057     0.056
>   100                0.056     0.056         0.057     0.057

100 is already far beyond the usual N values I've seen in real life,
and there is no measured difference here, so I don't see what problem
this is solving.

--
John Naylor
Amazon Web Services



pgsql-hackers by date:

Previous
From: "Hayato Kuroda (Fujitsu)"
Date:
Subject: RE: [PATCH] Explain what the default output_plugin_libraries do
Next
From: shveta malik
Date:
Subject: Re: Persist slot invalidations before publishing them