strange behavior of pg_trgm's similarity function

Поиск
Список
Период
Сортировка
От Fujii Masao
Тема strange behavior of pg_trgm's similarity function
Дата
Msg-id CAHGQGwGkawmurr8v96GjrqFvEhdJx9az77LZbWP8nrPwQtORCg@mail.gmail.com
обсуждение исходный текст
Ответы Re: strange behavior of pg_trgm's similarity function  (Heikki Linnakangas <hlinnakangas@vmware.com>)
Список pgsql-hackers
Hi,

The behavior of pg_trgm's similarity function seems strange. Is this
intentional?

I was thinking that the following three calls of the similarity function return
the same number because the second argument is just the three characters
contained in the first argument in every calls.

=# SELECT similarity('12345', '123');
=# SELECT similarity('12345', '234');
=# SELECT similarity('12345', '345');

But that's not true. Each returns the different number.

=# SELECT similarity('12345', '123');similarity
------------  0.428571
(1 row)

=# SELECT similarity('12345', '234');similarity
------------  0.111111
(1 row)

=# SELECT similarity('12345', '345');similarity
------------      0.25
(1 row)

This happens because, for example, similarity('12345', '123') returns
the similarity number of '**12345*' and '**123*' (* means the blank character),
NOT '12345' and '123'. IOW, two and one blank characters are added into
the heading and tailing of each argument, respectively. I wonder why
pg_trgm's similarity function works in this way. We should change this
so that no blank characters are added into the arguments?

Regards,

-- 
Fujii Masao



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

Предыдущее
От: pilum.70@uni-muenster.de
Дата:
Сообщение: Re: pg_stat_statements: calls under-estimation propagation
Следующее
От: Heikki Linnakangas
Дата:
Сообщение: Re: strange behavior of pg_trgm's similarity function