Re: strpos() && KMP

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: strpos() && KMP
Дата
Msg-id 22661.1186809312@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: strpos() && KMP  (Pavel Ajtkulov <ajtkulov@acm.org>)
Список pgsql-patches
Pavel Ajtkulov <ajtkulov@acm.org> writes:
> Tom Lane writes:
>> Moreover, you'd lose the guarantee of not-worse-than-linear time,
>> because hash lookup can be pathologically bad if you get a lot of hash
>> collisions.

> compute max_wchar, min_wchar. If (d = max_wchar - min_wchar) < k (for
> example, k = 1000), then we use index table (wchar -> wchar -
> min_wchar). Else we use hash table. Number of collisions would be a
> few (because hash table needs for pattern characters only.

I think you missed my point: there's a significant difference between
"guaranteed good performance" and "probabilistically good performance".
Even when the probably-good algorithm wins for typical cases, there's a
strong argument to be made for guarantees.  The problem you set out to
solve really is that an algorithm that's all right in everyday cases
will suck in certain uncommon cases --- so why do you want to fix it
by just moving around the cases in which it fails to do well?

            regards, tom lane

В списке pgsql-patches по дате отправления:

Предыдущее
От: Andrew Dunstan
Дата:
Сообщение: final CSVlog patch
Следующее
От: Michael Glaesemann
Дата:
Сообщение: Re: final CSVlog patch