[PATCH] Fix encoding-dependent LIKE/regex selectivity estimates

From: Chengpeng Yan <chengpeng_yan(at)outlook(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: Jeff Davis <pgsql(at)j-davis(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: [PATCH] Fix encoding-dependent LIKE/regex selectivity estimates
Date: 2026-11-18 11:08:17
Message-ID: 124D8863-5FFE-412A-B2E1-D07ACBD8FA38@outlook.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

LIKE/regex selectivity estimates for the same pattern depend on the
database encoding, because FIXED_CHAR_SEL is applied per byte rather
than per character. For example, `LIKE '%é'` is estimated at 0.2 in
LATIN1 but 0.04 in UTF8.

Patch attached.

--
Best regards,
Chengpeng Yan

Attachment Content-Type Size
v1-0001-Count-characters-not-bytes-in-pattern-selectivity.patch application/octet-stream 5.9 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Álvaro Herrera 2026-11-18 11:31:50 Re: psql: Don't offer partitioned tables after CREATE INDEX CONCURRENTLY
Previous Message Dave Cramer 2026-11-18 10:53:20 Re: Status of postgresql-interfaces/psqlodbc#228