Skip to content

Commit 19f6b83

Browse files
committed
Update script and grammar in optimize for ad hoc article
1 parent de2b9dd commit 19f6b83

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

docs/database-engine/configure-windows/optimize-for-ad-hoc-workloads-server-configuration-option.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: optimize for ad hoc workloads (server configuration option)
33
description: "Learn about the 'optimize for ad hoc workloads' option. Use it to improve SQL Server plan cache efficiency when workloads contain many single-use ad hoc batches."
44
author: rwestMSFT
55
ms.author: randolphwest
6-
ms.date: 12/18/2023
6+
ms.date: 12/28/2023
77
ms.service: sql
88
ms.subservice: configuration
99
ms.topic: conceptual
@@ -17,7 +17,7 @@ helpviewer_keywords:
1717

1818
The **optimize for ad hoc workloads** option is used to improve the efficiency of the plan cache for workloads that contain many single use ad hoc batches. When this option is set to `1`, the Database Engine stores a small compiled plan stub in the plan cache when a batch is compiled for the first time, instead of the full compiled plan. This option might help to relieve memory pressure by not allowing the plan cache to become filled with compiled plans that aren't reused. However, enabling this option might affect your ability to troubleshoot single-use plans.
1919

20-
The compiled plan stub allows the [!INCLUDE [ssDE](../../includes/ssde-md.md)] to recognize that this ad hoc batch was compiled before, only stores a compiled plan stub. When this batch is invoked (compiled or executed) again, the [!INCLUDE [ssDE](../../includes/ssde-md.md)] compiles the batch, removes the compiled plan stub from the plan cache, and adds the full compiled plan to the plan cache.
20+
The compiled plan stub allows the [!INCLUDE [ssDE](../../includes/ssde-md.md)] to recognize that this ad hoc batch was compiled previously, and only stores a compiled plan stub. When this batch is invoked (compiled or executed) again, the [!INCLUDE [ssDE](../../includes/ssde-md.md)] compiles the batch, removes the compiled plan stub from the plan cache, and adds the full compiled plan to the plan cache.
2121

2222
You can find compiled plan stubs by querying the `sys.dm_exec_cached_plans` catalog view and looking for "Compiled Plan" in the `cacheobjtype` column. The stub has a unique `plan_handle`. The compiled plan stub doesn't have an execution plan associated with it, and querying for the plan handle doesn't return a graphical or XML showplan.
2323

@@ -57,11 +57,11 @@ To find the number of single-use cached plans, run the following query:
5757
```sql
5858
SELECT objtype,
5959
cacheobjtype,
60-
AVG(usecounts) AS Avg_UseCount,
6160
SUM(refcounts) AS AllRefObjects,
6261
SUM(CAST(size_in_bytes AS BIGINT)) / 1024 / 1024 AS SizeInMB
6362
FROM sys.dm_exec_cached_plans
64-
WHERE objtype = 'Adhoc' AND usecounts = 1
63+
WHERE objtype = 'Adhoc'
64+
AND usecounts = 1
6565
GROUP BY objtype, cacheobjtype;
6666
```
6767

0 commit comments

Comments
 (0)