Re: sequential scan unduly favored over text search gin index

From: Jesper Krogh <jesper(at)krogh(dot)cc>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: sequential scan unduly favored over text search gin index
Date: 2011-06-20 18:58:58
Message-ID: 4DFF9872.6030104@krogh.cc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On 2011-06-20 17:38, Sushant Sinha 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. I set random_page_cost = 1.0 for
> the database to favor index use. However, I still see that the cost
> estimate for sequential scan of the entire table (23000) is cheaper than
> the cost of using the index (33000). The time taken for sequential
> access is 5200 ms and for index usage is only 85 ms.
The cost-estimation code for gin-indices are not good in 9.0, this has
hugely been improved in 9.1

http://git.postgresql.org/gitweb?p=postgresql.git&a=search&h=HEAD&st=commit&s=gincost

I think the individual patches apply quite cleanly to 9.0 as far
as I remember.

--
Jesper

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Tomas Vondra 2011-06-20 19:01:35 Re: sequential scan unduly favored over text search gin index
Previous Message Tom Lane 2011-06-20 16:08:19 Re: bad plan: 8.4.8, hashagg, work_mem=1MB.