| From: | Junwang Zhao <zhjwpku(at)gmail(dot)com> |
|---|---|
| To: | Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
| Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Small improvements to substring() |
| Date: | 2026-02-15 13:38:42 |
| Message-ID: | CAEG8a3Ko+OCW6-stTKjmcwBAcn2qdFez9XPua2h41dAudf5w7Q@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi Thomas,
On Sun, Feb 15, 2026 at 5:41 AM Thomas Munro <thomas(dot)munro(at)gmail(dot)com> 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Mihail Nikalayeu | 2026-02-15 16:03:00 | Re: Adding REPACK [concurrently] |
| Previous Message | John Naylor | 2026-02-15 13:04:01 | centralize CPU feature detection |