Skip to content

Commit 8a0aabc

Browse files
committed
Correct NOEXPAND guidance
1 parent 935dae0 commit 8a0aabc

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

docs/relational-databases/query-processing-architecture-guide.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: "How SQL Server processes queries and optimizes query reuse through
44
author: MikeRayMSFT
55
ms.author: mikeray
66
ms.reviewer: maghan, randolphwest, derekw
7-
ms.date: 01/16/2024
7+
ms.date: 01/14/2025
88
ms.service: sql
99
ms.topic: conceptual
1010
helpviewer_keywords:
@@ -348,7 +348,7 @@ The join order in the query plan is `Table1`, `Table2`, `TableA`, `TableB`, `Tab
348348

349349
As with any index, [!INCLUDE [ssNoVersion](../includes/ssnoversion-md.md)] chooses to use an indexed view in its query plan only if the Query Optimizer determines it is beneficial to do so.
350350

351-
Indexed views can be created in any edition of [!INCLUDE [ssNoVersion](../includes/ssnoversion-md.md)]. In some editions of some older versions of [!INCLUDE [ssNoVersion](../includes/ssnoversion-md.md)], the Query Optimizer automatically considers the indexed view. In some editions of some older versions of [!INCLUDE [ssNoVersion](../includes/ssnoversion-md.md)], to use an indexed view, the `NOEXPAND` table hint must be used. Prior to [!INCLUDE [ssSQL15_md](../includes/sssql16-md.md)] Service Pack 1, automatic use of an indexed view by the query optimizer is supported only in specific editions of [!INCLUDE [ssNoVersion](../includes/ssnoversion-md.md)]. Since, all editions support automatic use of an indexed view. [!INCLUDE [ssazure-sqldb](../includes/ssazure-sqldb.md)] and [!INCLUDE [ssazuremi-md](../includes/ssazuremi-md.md)] also support automatic use of indexed views without specifying the `NOEXPAND` hint.
351+
Indexed views can be created in any edition of [!INCLUDE [ssNoVersion](../includes/ssnoversion-md.md)]. In some editions of some older versions of [!INCLUDE [ssNoVersion](../includes/ssnoversion-md.md)], the Query Optimizer automatically considers the indexed view. In some editions of some older versions of [!INCLUDE [ssNoVersion](../includes/ssnoversion-md.md)], to use an indexed view, the `NOEXPAND` table hint must be used. Automatic use of an indexed view by the query optimizer is supported only in specific editions of [!INCLUDE [ssNoVersion](../includes/ssnoversion-md.md)]. [!INCLUDE [ssazure-sqldb](../includes/ssazure-sqldb.md)] and [!INCLUDE [ssazuremi-md](../includes/ssazuremi-md.md)] also support automatic use of indexed views without specifying the `NOEXPAND` hint.
352352

353353
The [!INCLUDE [ssNoVersion](../includes/ssnoversion-md.md)] Query Optimizer uses an indexed view when the following conditions are met:
354354

@@ -384,7 +384,7 @@ You can prevent view indexes from being used for a query by using the `EXPAND VI
384384

385385
- The `EXPAND VIEWS` option specifies that the Query Optimizer not use any view indexes for the whole query.
386386

387-
- When `NOEXPAND` is specified for a view, the Query Optimizer considers using any indexes defined on the view. `NOEXPAND` specified with the optional `INDEX()` clause forces the Query Optimizer to use the specified indexes. `NOEXPAND` can be specified only for an indexed view and can't be specified for a view not indexed. Prior to [!INCLUDE [ssSQL15_md](../includes/sssql16-md.md)] Service Pack 1, automatic use of an indexed view by the query optimizer is supported only in specific editions of [!INCLUDE [ssNoVersion](../includes/ssnoversion-md.md)]. Since, all editions support automatic use of an indexed view. [!INCLUDE [ssazure-sqldb](../includes/ssazure-sqldb.md)] and [!INCLUDE [ssazuremi-md](../includes/ssazuremi-md.md)] also support automatic use of indexed views without specifying the `NOEXPAND` hint.
387+
- When `NOEXPAND` is specified for a view, the Query Optimizer considers using any indexes defined on the view. `NOEXPAND` specified with the optional `INDEX()` clause forces the Query Optimizer to use the specified indexes. `NOEXPAND` can be specified only for an indexed view and can't be specified for a view not indexed. Automatic use of an indexed view by the query optimizer is supported only in specific editions of [!INCLUDE [ssNoVersion](../includes/ssnoversion-md.md)]. [!INCLUDE [ssazure-sqldb](../includes/ssazure-sqldb.md)] and [!INCLUDE [ssazuremi-md](../includes/ssazuremi-md.md)] also support automatic use of indexed views without specifying the `NOEXPAND` hint.
388388

389389
When neither `NOEXPAND` nor `EXPAND VIEWS` is specified in a query that contains a view, the view is expanded to access underlying tables. If the query that makes up the view contains any table hints, these hints are propagated to the underlying tables. (This process is explained in more detail in View Resolution.) As long as the set of hints that exists on the underlying tables of the view are identical to each other, the query is eligible to be matched with an indexed view. Most of the time, these hints will match each other, because they are being inherited directly from the view. However, if the query references tables instead of views, and the hints applied directly on these tables aren't identical, then such a query isn't eligible for matching with an indexed view. If the `INDEX`, `PAGLOCK`, `ROWLOCK`, `TABLOCKX`, `UPDLOCK`, or `XLOCK` hints apply to the tables referenced in the query after view expansion, the query isn't eligible for indexed view matching.
390390

@@ -1582,7 +1582,7 @@ GO
15821582

15831583
## Related content
15841584

1585-
- [Showplan Logical and Physical Operators Reference](showplan-logical-and-physical-operators-reference.md)
1585+
- [Logical and physical showplan operator reference](showplan-logical-and-physical-operators-reference.md)
15861586
- [Extended Events overview](extended-events/extended-events.md)
15871587
- [Best practices for monitoring workloads with Query Store](performance/best-practice-with-the-query-store.md)
15881588
- [Cardinality Estimation (SQL Server)](performance/cardinality-estimation-sql-server.md)

docs/relational-databases/views/create-indexed-views.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
2-
title: Create indexed views
2+
title: Create Indexed Views
33
description: Creating a unique clustered index on a view improves query performance, because the view is stored in the same way as a clustered index is stored.
44
author: WilliamDAssafMSFT
55
ms.author: wiassaf
66
ms.reviewer: randolphwest
7-
ms.date: 07/22/2024
7+
ms.date: 01/14/2025
88
ms.service: sql
99
ms.subservice: table-view-index
1010
ms.topic: conceptual
@@ -252,7 +252,7 @@ GROUP BY OrderDate
252252
ORDER BY OrderDate ASC;
253253
```
254254

255-
Finally, this example shows querying directly from the indexed view. Before [!INCLUDE [ssSQL15_md](../../includes/sssql16-md.md)] Service Pack 1, automatic use of an indexed view by the query optimizer is supported only in specific editions of [!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)]. On [!INCLUDE [ssnoversion-md](../../includes/ssnoversion-md.md)] Standard edition, you must use the `NOEXPAND` query hint to query the indexed view directly. Since [!INCLUDE [ssSQL15_md](../../includes/sssql16-md.md)] Service Pack 1, all editions support automatic use of an indexed view. [!INCLUDE [ssazure-sqldb](../../includes/ssazure-sqldb.md)] and [!INCLUDE [ssazuremi-md](../../includes/ssazuremi-md.md)] also support automatic use of indexed views without specifying the `NOEXPAND` hint. For more information, see [Table Hints (Transact-SQL)](../../t-sql/queries/hints-transact-sql-table.md#using-noexpand).
255+
Finally, this example shows querying directly from the indexed view. Automatic use of an indexed view by the query optimizer is supported only in specific editions of [!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)]. On [!INCLUDE [ssnoversion-md](../../includes/ssnoversion-md.md)] Standard edition, you must use the `NOEXPAND` query hint to query the indexed view directly. [!INCLUDE [ssazure-sqldb](../../includes/ssazure-sqldb.md)] and [!INCLUDE [ssazuremi-md](../../includes/ssazuremi-md.md)] support automatic use of indexed views without specifying the `NOEXPAND` hint. For more information, see [Table Hints (Transact-SQL)](../../t-sql/queries/hints-transact-sql-table.md#using-noexpand).
256256

257257
```sql
258258
--This query uses the indexed view directly, on Enterprise edition.

docs/t-sql/queries/hints-transact-sql-table.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Table hints override the default behavior of the query optimizer du
44
author: VanMSFT
55
ms.author: vanto
66
ms.reviewer: randolphwest
7-
ms.date: 12/16/2024
7+
ms.date: 01/14/2025
88
ms.service: sql
99
ms.subservice: t-sql
1010
ms.topic: reference
@@ -432,7 +432,7 @@ The query optimizer doesn't consider an index hint if the `SET` options don't ha
432432

433433
## Use NOEXPAND
434434

435-
`NOEXPAND` applies only to *indexed views*. An indexed view is a view with a unique clustered index created on it. If a query contains references to columns that are present both in an indexed view and base tables, and the query optimizer determines that using the indexed view provides the best method for executing the query, the query optimizer uses the index on the view. This functionality is called *indexed view matching*. Before [!INCLUDE [sssql16-md](../../includes/sssql16-md.md)] with Service Pack 1, automatic use of an indexed view by the query optimizer is supported only in specific editions of [!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)]. In [!INCLUDE [sssql16-md](../../includes/sssql16-md.md)] with Service Pack 1 and later versions, all editions support automatic use of an indexed view. [!INCLUDE [ssazure-sqldb](../../includes/ssazure-sqldb.md)] and [!INCLUDE [ssazuremi-md](../../includes/ssazuremi-md.md)] also support automatic use of indexed views without specifying the `NOEXPAND` hint.
435+
`NOEXPAND` applies only to *indexed views*. An indexed view is a view with a unique clustered index created on it. If a query contains references to columns that are present both in an indexed view and base tables, and the query optimizer determines that using the indexed view provides the best method for executing the query, the query optimizer uses the index on the view. This functionality is called *indexed view matching*. Automatic use of an indexed view by the query optimizer is supported only in specific editions of [!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)]. [!INCLUDE [ssazure-sqldb](../../includes/ssazure-sqldb.md)] and [!INCLUDE [ssazuremi-md](../../includes/ssazuremi-md.md)] also support automatic use of indexed views without specifying the `NOEXPAND` hint.
436436

437437
For more information, see [Query processing architecture guide](../../relational-databases/query-processing-architecture-guide.md#use-hints-with-indexed-views).
438438

0 commit comments

Comments
 (0)