Skip to content

Commit 2caa3b0

Browse files
Merge pull request #34560 from MikeRayMSFT/250627-uuf
Refresh with DC for standards.
2 parents c28f279 + f92e680 commit 2caa3b0

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

docs/relational-databases/indexes/create-filtered-indexes.md

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
2-
title: "Create filtered indexes"
2+
title: "Create Filtered Indexes"
33
description: A filtered index is an optimized disk-based rowstore nonclustered index especially suited to cover queries that select from a well-defined subset of data.
44
author: MikeRayMSFT
55
ms.author: mikeray
66
ms.reviewer: randolphwest
7-
ms.date: 10/14/2022
7+
ms.date: 06/27/2025
88
ms.service: sql
99
ms.subservice: table-view-index
1010
ms.topic: how-to
@@ -22,34 +22,37 @@ monikerRange: "=azuresqldb-current || >=sql-server-2016 || >=sql-server-linux-20
2222

2323
[!INCLUDE [SQL Server Azure SQL Database Azure SQL Managed Instance FabricSQLDB](../../includes/applies-to-version/sql-asdb-asdbmi-fabricsqldb.md)]
2424

25-
26-
This article describes how to create a filtered index using [!INCLUDE[ssManStudioFull](../../includes/ssmanstudiofull-md.md)] (SSMS) or [!INCLUDE[tsql](../../includes/tsql-md.md)]. A filtered index is an optimized disk-based rowstore nonclustered index especially suited to cover queries that select from a well-defined subset of data. It uses a filter predicate to index a portion of rows in the table. A well-designed filtered index can improve query performance and reduce index maintenance and storage costs compared with full-table indexes.
25+
This article describes how to create a filtered index using [!INCLUDE [ssManStudioFull](../../includes/ssmanstudiofull-md.md)] (SSMS) or [!INCLUDE [tsql](../../includes/tsql-md.md)]. A filtered index is an optimized disk-based rowstore nonclustered index especially suited to cover queries that select from a well-defined subset of data. It uses a filter predicate to index a portion of rows in the table. A well-designed filtered index can improve query performance and reduce index maintenance and storage costs compared with full-table indexes.
2726

2827
Filtered indexes can provide the following advantages over full-table indexes:
2928

3029
1. Improved query performance and plan quality.
3130

32-
A well-designed filtered index improves query performance and execution plan quality because it is smaller than a full-table nonclustered index and has filtered statistics. The filtered statistics are more accurate than full-table statistics because they cover only the rows in the filtered index.
31+
A well-designed filtered index improves query performance and execution plan quality because it's smaller than a full-table nonclustered index and has filtered statistics. The filtered statistics are more accurate than full-table statistics because they cover only the rows in the filtered index.
3332

3433
1. Reduced index maintenance costs.
3534

36-
An index is maintained only when data manipulation language (DML) statements affect the data in the index. A filtered index reduces index maintenance costs compared with a full-table nonclustered index because it is smaller and is only maintained when the data in the index is changed. It is possible to have a large number of filtered indexes, especially when they contain data that is changed infrequently. Similarly, if a filtered index contains only the frequently modified data, the smaller size of the index reduces the cost of updating the statistics.
35+
An index is maintained only when data manipulation language (DML) statements affect the data in the index. A filtered index reduces index maintenance costs compared with a full-table nonclustered index because it's smaller and is only maintained when the data in the index is changed. It's possible to have a large number of filtered indexes, especially when they contain data that is changed infrequently. Similarly, if a filtered index contains only the frequently modified data, the smaller size of the index reduces the cost of updating the statistics.
3736

3837
1. Reduced index storage costs.
3938

4039
Creating a filtered index can reduce disk storage for nonclustered indexes when a full-table index isn't necessary. You can replace a full-table nonclustered index with multiple filtered indexes without significantly increasing the storage requirements.
4140

42-
## <a id="Design"></a> Design considerations
41+
<a id="Design"></a>
42+
43+
## Design considerations
4344

44-
When a column only has a few relevant values for queries, you can create a filtered index on the subset of values. The resulting index will be smaller and cost less to maintain than a full-table nonclustered index defined on the same key columns.
45+
When a column only has a few relevant values for queries, you can create a filtered index on the subset of values. The resulting index will be smaller and cost less to maintain than a full-table nonclustered index defined on the same key columns.
4546

4647
For example, consider a filtered index in the following data scenarios. In each case, the `WHERE` clause of the query should be a subset of the `WHERE` clause of the filtered index, to benefit from the filtered index.
4748

48-
- When the values in a column are mostly NULL and the query selects only from the non-NULL values. You can create a filtered index for the non-NULL data rows.
49+
- When the values in a column are mostly `NULL` and the query selects only from the non-NULL values. You can create a filtered index for the non-NULL data rows.
4950
- When rows in a table are marked as processed by a recurring workflow or queue process. Over time, most rows in the table will be marked as processed. A filtered index on rows that aren't yet processed would benefit the recurring query that looks for rows that aren't yet processed.
5051
- When a table has heterogeneous data rows. You can create a filtered index for one or more categories of data. This can improve the performance of queries on these data rows by narrowing the focus of a query to a specific area of the table. Again, the resulting index will be smaller and cost less to maintain than a full-table nonclustered index.
5152

52-
## <a id="Restrictions"></a> Limitations and restrictions
53+
<a id="Restrictions"></a>
54+
55+
## Limitations
5356

5457
- You can't create a filtered index on a view. However, the query optimizer can benefit from a filtered index defined on a table that is referenced in a view. The query optimizer considers a filtered index for a query that selects from a view if the query results will be correct.
5558

@@ -87,7 +90,9 @@ For example, consider a filtered index in the following data scenarios. In each
8790

8891
Requires ALTER permission on the table or view. The user must be a member of the **sysadmin** fixed server role or the **db_ddladmin** and **db_owner** fixed database roles. To modify the filtered index expression, use `CREATE INDEX WITH DROP_EXISTING`.
8992

90-
## <a id="SSMSProcedure"></a> Create a filtered index with SSMS
93+
<a id="SSMSProcedure"></a>
94+
95+
## Create a filtered index with SSMS
9196

9297
1. In Object Explorer, select the plus sign to expand the database that contains the table on which you want to create a filtered index.
9398

@@ -109,11 +114,13 @@ Requires ALTER permission on the table or view. The user must be a member of the
109114

110115
1. Select **OK**.
111116

112-
## <a id="TsqlProcedure"></a> Create a filtered index with Transact-SQL
117+
<a id="TsqlProcedure"></a>
118+
119+
## Create a filtered index with Transact-SQL
113120

114121
[!INCLUDE [article-uses-adventureworks](../../includes/article-uses-adventureworks.md)]
115122

116-
1. In **Object Explorer**, connect to an instance of [!INCLUDE[ssDE](../../includes/ssde-md.md)].
123+
1. In **Object Explorer**, connect to an instance of [!INCLUDE [ssDE](../../includes/ssde-md.md)].
117124

118125
1. On the Standard bar, select **New Query**.
119126

@@ -133,7 +140,7 @@ CREATE NONCLUSTERED INDEX FIBillOfMaterialsWithEndDate
133140
GO
134141
```
135142

136-
The filtered index `FIBillOfMaterialsWithEndDate` is valid for the following query. [You can display the query execution plan](../performance/display-an-actual-execution-plan.md) to determine if the query optimizer used the filtered index.
143+
The filtered index `FIBillOfMaterialsWithEndDate` is valid for the following query. [Display an actual execution plan](../performance/display-an-actual-execution-plan.md) to determine if the query optimizer used the filtered index.
137144

138145
```sql
139146
USE AdventureWorks2022;
@@ -147,11 +154,9 @@ WHERE EndDate IS NOT NULL
147154
GO
148155
```
149156

150-
## Next steps
151-
152-
To learn more about creating indexes and related concepts, see the following articles:
157+
## Related content
153158

154159
- [CREATE INDEX (Transact-SQL)](../../t-sql/statements/create-index-transact-sql.md)
155160
- [SQL Server and Azure SQL index architecture and design guide](../sql-server-index-design-guide.md)
156161
- [Display an actual execution plan](../performance/display-an-actual-execution-plan.md)
157-
- [Index types](indexes.md)
162+
- [Indexes](indexes.md)

0 commit comments

Comments
 (0)