Re: SeqScan with full text search

Поиск
Список
Период
Сортировка
От Віталій Тимчишин
Тема Re: SeqScan with full text search
Дата
Msg-id CABWW-d2YQHQn7vZwxJTVJ1xjhZa+Y9R5t3auE+w9QSjJHG7wVg@mail.gmail.com
обсуждение исходный текст
Ответ на SeqScan with full text search  (Tomek Walkuski <tomek.walkuski@gmail.com>)
Список pgsql-performance


2012/4/16 Tomek Walkuski <tomek.walkuski@gmail.com>
Hello group!

I have query like this:

SELECT
 employments.candidate_id AS candidate_id,
 SUM(TS_RANK(employers.search_vector, TO_TSQUERY('simple', 'One:* |
Two:* | Three:* | Four:*'), 2)) AS ts_rank
FROM
 employments
INNER JOIN
 employers ON employments.employer_id = employers.id
AND
 employers.search_vector @@ TO_TSQUERY('simple', 'One:* | Two:* |
Three:* | Four:*')
GROUP BY
 candidate_id;

And it results with this:

http://explain.depesz.com/s/jLM

The JOIN between employments and employers is the culprit. I'm unable
to get rid of the seq scan, and setting enable_seqscan to off makes
things even worse.

Is there any way to get rid of this JOIN?


Have you got an index on employments.employer_id? It seems for me that only some employments get out of join, so index would help here. What's the plan with seq_scan off?

P.S. I don't see why all employments are needed. May be I am reading something wrong? For me it's max 2616 employments out of 1606432.

Best regards, Vitalii Tymchyshyn

--
Best regards,
 Vitalii Tymchyshyn

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

Предыдущее
От: Merlin Moncure
Дата:
Сообщение: Re: SeqScan with full text search
Следующее
От: Scott Marlowe
Дата:
Сообщение: Re: H800 + md1200 Performance problem