MySQL Forums
Forum List  »  Performance

Use of index for SELECT DISTINCT
Posted by: Dominique PRUNIER
Date: June 07, 2005 07:19PM

Hello,

I may be wrong but i find something strange in index use when selecting distinct value. For example, let's assume we have a table like that:

a: integer
b: varchar(128)

Let's say that b has only a few distinct values but the table has MANY rows (2 000 000). The column b is indexed, with of course a VERY low cardinality.

Why optmimizer will always scan the 2 000 000 (using index on b though) to execute query SELECT DISTINCT b FROM table while it knows there are only a few distincts values from the index ?

Thanks

Options: ReplyQuote


Subject
Views
Written By
Posted
Use of index for SELECT DISTINCT
3257
June 07, 2005 07:19PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.