Hi, > On Nov 25, 2026, at 00:12, Tom Lane <[email protected]> wrote: > > I don't quite agree with that definition: a length restriction is > not "no constraint". But that's a side point. > > Yes, we could distinguish cases where the pattern is like "abc%" > or "^abc", and maybe that's common enough to be worth the trouble, > but I'm not really convinced. I think when we put in the > check-all-the-histogram-entries logic we eliminated pretty much > all reason to work hard on pattern analysis. The fixed-prefix > logic is worth keeping because it allows a preliminary index-based > filter, but I think we should stop with that rather than trying > to do fragmentary pattern analysis. > > regards, tom lane
Agreed. I will not do any further analysis of the pattern: rest_selec becomes DEFAULT_MATCH_SEL, and everything that was used to compute it is removed: heursel = prefixsel * rest_selec; <- today heursel = prefixsel * DEFAULT_MATCH_SEL; <- proposed 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. 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? -- Best regards, Chengpeng Yan
v3-0001-Simplify-pattern-selectivity-estimation.patch
Description: v3-0001-Simplify-pattern-selectivity-estimation.patch
