Re: NOT LIKE much faster than LIKE? - Mailing list pgsql-performance

From Tom Lane
Subject Re: NOT LIKE much faster than LIKE?
Date
Msg-id 24372.1136861684@sss.pgh.pa.us
Whole thread Raw
In response to Re: NOT LIKE much faster than LIKE?  (Andrea Arcangeli <andrea@cpushare.com>)
Responses Re: NOT LIKE much faster than LIKE?  (Andrea Arcangeli <andrea@cpushare.com>)
Re: NOT LIKE much faster than LIKE?  (Matteo Beccati <php@beccati.com>)
List pgsql-performance
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

pgsql-performance by date:

Previous
From: Andrea Arcangeli
Date:
Subject: Re: NOT LIKE much faster than LIKE?
Next
From: Stephan Szabo
Date:
Subject: Re: NOT LIKE much faster than LIKE?