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

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [pg_trgm] Making similarity(?, ?) < ? use an index
Дата
Msg-id 23767.1464984127@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: [pg_trgm] Making similarity(?, ?) < ? use an index  (Jeff Janes <jeff.janes@gmail.com>)
Ответы Re: [pg_trgm] Making similarity(?, ?) < ? use an index  (Jeff Janes <jeff.janes@gmail.com>)
Список pgsql-general
Jeff Janes <jeff.janes@gmail.com> writes:
> On Fri, Jun 3, 2016 at 12:13 PM, Greg Navis <contact@gregnavis.com> wrote:
>> I'm curious ... would it be difficult to modify PostgreSQL so that it'd use
>> the index for `similarity(lhs, rhs) >= show_limit()` too?

> Yes, that would be very difficult. The project has kind of painted
> itself into a corner on that.

Well, the thing that is not easy to change is that index scans require
qualifiers expressed as "indexed_column indexable_operator something".
But there's a lot of flexibility about what "something" is.  You could
imagine doing, say,

    foo ~~ similarity_rhs('bar', 0.01)

where the function just collects its arguments into some composite type
that we provide an indexable operator to compare strings to.

> If it were easy, I doubt we would have added the % operator with the
> ugly set_limit() wart in the first place (although I was not around at
> the time that was done--maybe there were other considerations).

I think that was just bad design.  There's a lot of old stuff in contrib
that hasn't been vetted all that closely.

            regards, tom lane


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

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: [pg_trgm] Making similarity(?, ?) < ? use an index
Следующее
От: Jeff Janes
Дата:
Сообщение: Re: [pg_trgm] Making similarity(?, ?) < ? use an index