If you have a table with 500 million rows and you create an index on a column where there are only 5 different values, SQL Server is likely to ignore the index when running your queries.
Basically, if most of the data is not selective enough, it would take SQL Server longer to use the index data than it would to do a table scan (or clustered index scan).
This concept changes drastically when there are additional limits on the data. For example, if you are joining tables with a high selectivity and filtering on a low selectivity column, you could create an index on the high selectivity column and include the low selectivity column. A lot of this depends on the queries involved and also what the data looks like.
If you want to post your query and indicate the column that only has 5 distinct values, we may be able to offer suggestions regarding indexes to help speed up the query.
-George
Microsoft SQL Server MVP My Blogs SQLCop
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.