When an index is created, SQL Server generates a structure called a histogram that stores information about the relative distribution of data values within a column. The degree to which values in the column allow you to locate small sets of data is referred to as the selectivity of the index. As the number of unique values within a column increases, the selectivity of an index increases. The query optimizer chooses the most selective indexes to satisfy a query because a highly selective index allows the query processor to eliminate a very large portion of the table so as to access the least amount of data necessary to satisfy your query. Indexes with low selectivity and a low percentage of unique values are not considered by the query optimizer, but they still incur an overhead for write operations.
Filtered indexes have the following restrictions:
- They must be a nonclustered index.
- They cannot be created on computed columns.
- Columns cannot undergo implicit or explicit data type conversion.
Eg:
CREATE NONCLUSTERED INDEX idx_city2
ON Person.Address(City)
INCLUDE (AddressLine1, AddressLine2)
WHERE AddressLine2 IS NOT NULL
After going through many articles on the web, I found one article which I think is the best article on Filtered Indexes in SQL Server 2008. This article is a blog post by Randy Dyess from Solid Quality Mentors.
No comments:
Post a Comment