Re: select distinct and index usage - Mailing list pgsql-general

From Tom Lane
Subject Re: select distinct and index usage
Date
Msg-id 13570.1207620903@sss.pgh.pa.us
Whole thread Raw
In response to Re: select distinct and index usage  ("David Wilson" <david.t.wilson@gmail.com>)
Responses Re: select distinct and index usage  (Alvaro Herrera <alvherre@commandprompt.com>)
List pgsql-general
"David Wilson" <david.t.wilson@gmail.com> writes:
> It appears to be doing a sequential scan regardless of the set, as if
> it doesn't believe it can use the index for some reason

More likely, it's getting a cost estimate for the indexscan that's so
bad that it even exceeds the 100000000-unit thumb on the scales that's
inserted by enable_seqscan=off.

You could try setting enable_sort=off also, which'd give you another
100000000 worth of thumb on the scales.  And if that doesn't help,
reduce random_page_cost to 1 or even less.

What I think you'll find, though, is that once you do force an indexscan
to be picked it'll be slower.  Full-table index scans are typically
worse than seqscan+sort, unintuitive though that may sound.

            regards, tom lane

pgsql-general by date:

Previous
From: "Markus Wollny"
Date:
Subject: tsvector_update_trigger throws error "column is not of tsvector type"
Next
From: Alvaro Herrera
Date:
Subject: Re: select distinct and index usage