Re: SeqScan with full text search

From: Віталій Тимчишин <tivv00(at)gmail(dot)com>
To: Tomek Walkuski <tomek(dot)walkuski(at)gmail(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: SeqScan with full text search
Date: 2012-04-17 17:12:26
Message-ID: CABWW-d2YQHQn7vZwxJTVJ1xjhZa+Y9R5t3auE+w9QSjJHG7wVg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

2012/4/16 Tomek Walkuski <tomek(dot)walkuski(at)gmail(dot)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

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Віталій Тимчишин 2012-04-18 06:51:19 Re: bad planning with 75% effective_cache_size
Previous Message Istvan Endredy 2012-04-17 09:49:57 Re: bad planning with 75% effective_cache_size