Subject Re: Natural Plan when grouping by 5 indexed columns?
Author Adam
> I think my point is that one could just read the indecies in disk
> order and skip the actual rows data, reducing the number of reads by
> 95%.

As a MGA database, the index nodes contain uncommitted inserts,
records that your transaction can not see due to isolation, and
deleted records yet to be garbage collected. It is not enough to look
at the index. The data page shows whether your transaction can see a
specific record.

That said, if the index had 'poor enough' selectivity, it may be less
expensive to do an indexed walk for distinctness, although you would
get thrashing, it would possibly be in cases similar to yours faster.
The distict operator does not try this optimisation (in 1.5.x anyway).
I don't know whether it is just something not considered or whether
there is some other logical fault that means it is unreliable, or
whether it is just too hard to guess when to use which approach.