DEFINITIONS

Definitions More Info.
Definition ID265
TitleSQL
CategorySCRIPT
DefinitionSQL 2008-2012 filtered index
Definition Description SQL SERVER – 2008 – Introduction to Filtered Index – Improve performance with Filtered Index September 1, 2008 by pinaldave Filtered Index is a new feature in SQL SERVER 2008. Filtered Index is used to index a portion of rows in a table that means it applies filter on INDEX which improves query performance, reduce index maintenance costs, and reduce index storage costs compared with full-table indexes. When we see an Index created with some WHERE clause then that is actually a FILTERED INDEX. For Example, If we want to get the Employees whose Title is “Marketing Manager”, for that let’s create an INDEX on EmployeeID whose Title is “Marketing Manager” and then write the SQL Statement to retrieve Employees who are “Marketing Manager”. CREATE NONCLUSTERED INDEX NCI_Department ON HumanResources.Employee(EmployeeID) WHERE Title= 'Marketing Manager' Points to remember when creating Filtered Index: - They can be created only as Nonclustered Index - They can be used on Views only if they are persisted views. - They cannot be created on full-text Indexes. Let us write simple SELECT statement on the table where we created Filtered Index. SELECT he.EmployeeID,he.LoginID,he.Title FROM HumanResources.Employee he WHERE he.Title = 'Marketing Manager' Now we will see the Execution Plan and compare the performance before and after the Filtered Index was created on Employee table. As we can see, in first case the index scan in 100% done on Clustered Index taking 24% of total cost of execution. Once the Filtered index was created on Employee table, the Index scan is 50% on Clustered Index and 50% on Nonclustered Index which retrieves the data faster taking 20% of total cost of execution compared to 24% on table with no index.
RecordBycunay
Record Date31-10-2012 12:34:38
Düzenle
Kopyala
Sil