Hi Thomas,
On Sun, Feb 15, 2026 at 5:41 AM Thomas Munro <[email protected]> wrote:
>
> Hi,
>
> As recently discussed on pgsql-bugs[1], substring() does unnecessary
> work that can easily be deleted. Here's a patch to try that.
>
> [1]
> https://www.postgresql.org/message-id/flat/19406-9867fddddd724fca%40postgresql.org
A simple benchmark indicates an approximately 20% performance improvement.
I have not identified any corner cases where the patch would introduce
regressions, so +1.
I test it on an old intel chip mac, test query used:
EXPLAIN ANALYZE
SELECT substring(repeat('中', i * 2), 1, i)
FROM generate_series(1, 10000) AS i;
--
Regards
Junwang Zhao