Re: sequential scan unduly favored over text search gin index - Mailing list pgsql-performance

From Tomas Vondra
Subject Re: sequential scan unduly favored over text search gin index
Date
Msg-id 4DFF990F.8080906@fuzzy.cz
Whole thread Raw
In response to Re: sequential scan unduly favored over text search gin index  (Sushant Sinha <sushant354@gmail.com>)
Responses Re: sequential scan unduly favored over text search gin index  (Sushant Sinha <sushant354@gmail.com>)
List pgsql-performance
Dne 20.6.2011 18:04, Sushant Sinha napsal(a):
>
> On Mon, 2011-06-20 at 10:58 -0500, Kevin Grittner wrote:
>> Sushant Sinha <sushant354@gmail.com> wrote:
>>
>>> I have a tsvector column docvector and a gin index on it
>>> docmeta1_docvector_idx
>>>
>>> I have a simple query "select * from docmeta1 where docvector @@
>>> plainto_tsquery('english', 'free');"
>>>
>>> I find that the planner chooses a sequential scan of the table
>>> even when the index performs orders of magnitude.
>>
>> Did you ANALYZE the table after loading the data and building the
>> index?
> Yes and I mentioned that the row estimates are correct, which indicate
> that the problem is somewhere else.

Hi,

I agree the estimates are damn precise in this case (actually the
estimates are exact). The problem is the planner thinks the seq scan is
about 30% cheaper than the bitmap index scan.

I guess you could poke the planner towards the bitmap scan by lowering
the random_page_cost (the default value is 4, I'd say lowering it to 2
should do the trick).

But be careful, this will influence all the other queries! Those values
should somehow reflect the hardware of your system (type of drives,
amount of RAM, etc.) so you have to test the effects.


regards
Tomas

pgsql-performance by date:

Previous
From: Jesper Krogh
Date:
Subject: Re: sequential scan unduly favored over text search gin index
Next
From: Tomas Vondra
Date:
Subject: Re: how to know slowly query in lock postgre