Re: select distinct and index usage

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: David Wilson <david(dot)t(dot)wilson(at)gmail(dot)com>, Alban Hertroys <dalroi(at)solfertje(dot)student(dot)utwente(dot)nl>, pgsql-general(at)postgresql(dot)org
Subject: Re: select distinct and index usage
Date: 2008-04-08 02:30:31
Message-ID: 13767.1207621831@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
> Tom Lane escribi:
>> 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.

> Hmm, should we switch the CLUSTER code to do that?

It's been suggested before, but I'm not sure. The case where an
indexscan can win is where the table is roughly in index order already.
So if you think about periodic CLUSTER to maintain table ordering,
I suspect you'd want the indexscan implementation for all but maybe
the first time.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Manuel Sugawara 2008-04-08 02:37:11 Re: Cannot use a standalone backend to VACUUM in "postgres""
Previous Message Alvaro Herrera 2008-04-08 02:16:58 Re: select distinct and index usage