Re: select distinct, index not used
| От | Sam Mason |
|---|---|
| Тема | Re: select distinct, index not used |
| Дата | |
| Msg-id | 20090416164247.GP12225@frubble.xen.chris-lamb.co.uk обсуждение исходный текст |
| Ответ на | Re: select distinct, index not used (Tom Lane <tgl@sss.pgh.pa.us>) |
| Ответы |
Re: select distinct, index not used
|
| Список | pgsql-general |
On Thu, Apr 16, 2009 at 11:29:25AM -0400, Tom Lane wrote:
> , a full table indexscan isn't going to be particularly fast in
> any case; it's often the case that seqscan-and-sort is the right
> decision.
Is PG capable of "skipping" over duplicate values using an index?
For example, if I've got a table like:
CREATE TABLE foo (
id INTEGER PRIMARY KEY,
v1 BOOLEAN
);
that contains several million rows and I do a query like:
SELECT DISTINCT v1 FROM foo;
PG should only need to read three tuples from the table (assuming there
are no dead rows). I've had a look in the TODO, but haven't found
anything similar. This is obviously only a win when there are few
distinct values from compared to the number of rows.
--
Sam http://samason.me.uk/
В списке pgsql-general по дате отправления: