Find similar records (compare tsvectors)

Поиск
Список
Период
Сортировка
От Patrick Dung
Тема Find similar records (compare tsvectors)
Дата
Msg-id 514327739.917376.1425308276228.JavaMail.yahoo@mail.yahoo.com
обсуждение исходный текст
Ответы Re: Find similar records (compare tsvectors)  (Patrick Dung <patrick_dkt@yahoo.com.hk>)
Список pgsql-general
Hello,

I had a database with articles or attachment stored in bytea format.
I also had a trigger: it insert/update the tsv column when a record is added/updated.
The tsv column had a GIN index.
With this setting, I can do very fast keyword search on the tsv.

Suppose I had a specific record (id=100000).
How to list similar records based on ranking?
In that case, I had to compare a tsvector with another tsvector.

I had this SQL which make the original tsv as a text and then to tsquery, Then I can compare a tsv and a tsquery.
SELECT ts_rank(i.tsv, replace(strip(original.tsv)::text, ' ', '|')::tsquery) as similarity, i.company, i.industry, i.post_timestamp, i.id FROM items i, (SELECT tsv, id FROM items WHERE id=100000) AS original WHERE i.id != original.id ORDER BY similarity;

items table:
id bigint
company varchar
industry varchar
description varchar
post_timestamp timestamp
attachment bytea
tsv tsvector

The problem is that this is very slow.
Any comment?

Thank and regards,
Patrick

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

Предыдущее
От: Ryan King
Дата:
Сообщение: Re: Regarding "Point-in-time Recovery" feature
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: The slave suddenly stopped with such DB log : "will not overwrite a used ItemId" and "heap_insert_redo: failed to add tuple"