Andrea Arcangeli <andrea@cpushare.com> writes:
> If you don't know the data, I think it's a bug that LIKE is assumed to
> have a selectivity above 50%.
Extrapolating from the observation that the heuristics don't work well
on your data to the conclusion that they don't work for anybody is not
good logic. Replacing that code with a flat 50% is not going to happen
(or if it does, I'll be sure to send the mob of unhappy users waving
torches and pitchforks to your door not mine ;-)).
I did just think of something we could improve though. The pattern
selectivity code doesn't make any use of the statistics about "most
common values". For a constant pattern, we could actually apply the
pattern test with each common value and derive answers that are exact
for the portion of the population represented by the most-common-values
list. If the MCV list covers a large fraction of the population then
this would be a big leg up in accuracy. Dunno if that applies to your
particular case or not, but it seems worth doing ...
regards, tom lane