Re: Speed up lpad() and rpad() for one-byte padding strings

From: John Naylor <johncnaylorls(at)gmail(dot)com>
To: Sehrope Sarkuni <sehrope(at)jackdb(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Speed up lpad() and rpad() for one-byte padding strings
Date: 2026-09-24 05:21:27
Message-ID: CANWCAZaB8NsQJrKc-pxRTj_=C8CBOTDEWkPW0Eur=ymUSbUwZQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Sep 23, 2026 at 9:10 PM Sehrope Sarkuni <sehrope(at)jackdb(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message shveta malik 2026-09-24 05:25:03 Re: Persist slot invalidations before publishing them
Previous Message Hayato Kuroda (Fujitsu) 2026-09-24 05:18:49 RE: [PATCH] Explain what the default output_plugin_libraries do