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

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

Chengpeng Yan <chengpeng_yan(at)outlook(dot)com> writes:
> One test result changes: one EXPLAIN in the statistics-privileges block of
> inherit.sql goes from hash join to nested loop. With no stats available
> its estimate was about 4% (counting the pattern's characters) and is now
> 0.5%, so the plan changes as expected.

Bleah. It's really not acceptable to change the expected results
like that: the point of that set of tests is to show that we hide
statistics when we are supposed to. So if the plan is just like the
plan you get when you do have statistics access, then the test is
useless.

> If we want the test to keep telling us, through the join method, whether
> the stats were usable, I would change the pattern from 'a1$' to
> '^[0-9a-f]', so that it matches almost every value: with the stats it
> estimates 100% and picks a hash join, without them the 0.5% fallback picks
> a nested loop. Any other idea, or should I just update the expected
> output?

Yeah, that works. I tried to find alternatives that preserved the
existing direction of choice between nestloop and hash plans, but
I couldn't do it without increasing the size of the test table,
which'd be a high price to pay to keep the test looking the same.
Flipping between hash and nestloop is fine anyway for this purpose:
we just need to get different plans for the two cases.

Pushed with that adjustment and some minor comment-editing.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2026-11-25 22:31:36 Re: Unify parallel worker handling for index builds and instrumentation
Previous Message Hannu Krosing 2026-11-25 22:18:19 Storing Property Graphs like Views (as a serialized analyzed parse tree)