| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Fix LIKE/regex optimization for indexscan with exact-match patte |
| Date: | 2026-07-06 17:06:45 |
| Message-ID: | E1wgmmL-001cNn-19@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
Fix LIKE/regex optimization for indexscan with exact-match pattern.
Commit 85b7efa1c introduced support for LIKE with non-deterministic
collations. By moving some conditionals around, it accidentally broke
the optimization for converting a LIKE or regex exact-match pattern
to an equality indexqual when the index collation doesn't match the
expression collation. That should be allowed if the expression
collation is deterministic. This patch re-introduces the optimization
for that common case.
One important beneficiary of this optimization is the "\d tablename"
command in psql. Without this fix that will do a seqscan on pg_class
instead of an index point lookup.
Reported-by: Andres Freund <andres(at)anarazel(dot)de>
Author: Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>
Reviewed-by: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Discussion: https://postgr.es/m/DHBQIZX8SZVI.ZX614ZMFL645@jeltef.nl
Backpatch-through: 18
Branch
------
REL_18_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/d0bb49e61168953f0f07c3beeb2b8fb63a3521a2
Modified Files
--------------
src/backend/utils/adt/like_support.c | 20 ++++++++++++++++----
src/test/regress/expected/collate.icu.utf8.out | 23 +++++++++++++++++++++++
src/test/regress/expected/collate.out | 23 +++++++++++++++++++++++
src/test/regress/sql/collate.icu.utf8.sql | 10 ++++++++++
src/test/regress/sql/collate.sql | 10 ++++++++++
5 files changed, 82 insertions(+), 4 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2026-07-06 17:48:47 | pgsql: Make PLy_elog() use pg_integer_constant_p(). |
| Previous Message | Robert Haas | 2026-07-06 17:04:31 | pgsql: Prevent satisfies_hash_partition from crashing with VARIADIC NUL |