Re: NOT LIKE much faster than LIKE?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrea Arcangeli <andrea(at)cpushare(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: NOT LIKE much faster than LIKE?
Date: 2006-01-10 02:54:44
Message-ID: 24372.1136861684@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Andrea Arcangeli <andrea(at)cpushare(dot)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

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Stephan Szabo 2006-01-10 02:54:57 Re: NOT LIKE much faster than LIKE?
Previous Message Andrea Arcangeli 2006-01-10 02:45:34 Re: NOT LIKE much faster than LIKE?