Skip site navigation (1) Skip section navigation (2)

Re: Query planner doesn't use index scan on tsvector GIN index if LIMIT is specifiedQuery planner doesn't use index scan on tsvector GIN index if LIMIT is specified

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: darklow <darklow(at)gmail(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Query planner doesn't use index scan on tsvector GIN index if LIMIT is specifiedQuery planner doesn't use index scan on tsvector GIN index if LIMIT is specified
Date: 2012-01-10 17:04:34
Message-ID: 25378.1326215074@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-performance
darklow <darklow(at)gmail(dot)com> writes:
> But the performance problems starts when i do the same query specifying
> LIMIT.
> *SELECT id FROM cache WHERE tsv @@ to_tsquery('test:*') limit 20;*
> By some reason index is not used.

It apparently thinks there are enough matches that it might as well just
seqscan the table and expect to find some matches at random, in less
time than using the index would take.

The estimate seems to be off quite a bit, so maybe raising the stats
target for this column would help.

			regards, tom lane

In response to

Responses

pgsql-performance by date

Next:From: Andreas KretschmerDate: 2012-01-10 17:09:37
Subject: Re: Partitioning by status?
Previous:From: Mike BlackwellDate: 2012-01-10 16:57:04
Subject: Partitioning by status?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group