Re: [pg_trgm] Making similarity(?, ?) < ? use an index

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: [pg_trgm] Making similarity(?, ?) < ? use an index
Дата
Msg-id CAKFQuwb=4oyK1S7xRs__TrNzVEJChVUw84pBO-qX_ScpPTz9eA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [pg_trgm] Making similarity(?, ?) < ? use an index  (Greg Navis <contact@gregnavis.com>)
Список pgsql-general
On Fri, Jun 3, 2016 at 3:13 PM, Greg Navis <contact@gregnavis.com> wrote:
Thanks for answers and sorry for not searching hard enough.

I'm curious ... would it be difficult to modify PostgreSQL so that it'd use the index for `similarity(lhs, rhs) >= show_limit()` too?

​Not in a way that would be useful.
Or even add `is_similar(lhs, rhs, threshold)` that'd allow to change the threshold on a per-query basis. I might be able to block some time to contribute.

​I can see that being a useful API to add to pg_trgm.  While it wouldn't solve your indexing problem - it would at least make using cases that are already un-indexable easier to write and comprehend.  The particular problem for the other poster was wanting two different values within the same query - which is impossible in the current setup but would be made possible with such a function.

I'm not sure how much effort the following would take but if we cannot change the tie between indexes and operators maybe we can introduce ternary operators that can be assigned to index opclasses.

Something like:

lhs % rhs # 40 => similarity(lhs, rhs, 70)
lhs % rhs # 70 => similarity(lhs, rhs, 70)

It would have the added benefit of allowing us to add the main ternary operator <?:> instead of convoluted CASE statements for verbose functional forms.

David J.

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

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: PL/PGSQL + inserts+updates+limit - Postgres 9.3
Следующее
От: Jeff Janes
Дата:
Сообщение: Re: [pg_trgm] Making similarity(?, ?) < ? use an index