Skip to content

Commit 7ffefdc

Browse files
authored
Merge pull request #4441 from joesackmsft/patch-14
Document OPTIMIZE_FOR_AD_HOC_WORKLOADS
2 parents ebff2e8 + 4881e94 commit 7ffefdc

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

docs/t-sql/statements/alter-database-scoped-configuration-transact-sql.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "ALTER DATABASE SCOPED CONFIGURATION (Transact-SQL) | Microsoft Docs"
33
ms.custom: ""
4-
ms.date: "07/27/2017"
4+
ms.date: "01/04/2018"
55
ms.prod: "sql-non-specified"
66
ms.prod_service: "database-engine, sql-database"
77
ms.service: ""
@@ -46,6 +46,8 @@ ms.workload: "On Demand"
4646
- Enable or disable query optimization hotfixes at the database level.
4747

4848
- Enable or disable the identity cache at the database level.
49+
50+
- Enable or disable a compiled plan stub to be stored in cache when a batch is compiled for the first time.
4951

5052
![link icon](../../database-engine/configure-windows/media/topic-link.gif "link icon") [Transact-SQL Syntax Conventions](../../t-sql/language-elements/transact-sql-syntax-conventions-transact-sql.md)
5153

@@ -67,6 +69,7 @@ ALTER DATABASE SCOPED CONFIGURATION
6769
| PARAMETER_SNIFFING = { ON | OFF | PRIMARY}
6870
| QUERY_OPTIMIZER_HOTFIXES = { ON | OFF | PRIMARY}
6971
| IDENTITY_CACHE = { ON | OFF }
72+
| OPTIMIZE_FOR_AD_HOC_WORKLOADS = { ON | OFF }
7073
}
7174
```
7275

@@ -141,6 +144,12 @@ Enables or disables identity cache at the database level. The default is **ON**.
141144
> [!NOTE]
142145
> This option can only be set for the PRIMARY. For more information, see [identity columns](create-table-transact-sql-identity-property.md).
143146
147+
OPTIMIZE_FOR_AD_HOC_WORKLOADS **=** { ON | **OFF** }
148+
149+
**Applies to**: [!INCLUDE[ssSDS](../../includes/sssds-md.md)]
150+
151+
Enables or disables a compiled plan stub to be stored in cache when a batch is compiled for the first time. The default is OFF. Once the database scoped configuration OPTIMIZE_FOR_AD_HOC_WORKLOADS is enabled for a database, a compiled plan stub will be stored in cache when a batch is compiled for the first time. Plan stubs have a smaller memory footprint compared to the size of the full compiled plan. If a batch is compiled or executed again, the compiled plan stub will be removed and replaced with a full compiled plan.
152+
144153
## <a name="Permissions"></a> Permissions
145154
Requires ALTER ANY DATABASE SCOPE CONFIGURATION
146155
on the database. This permission can be granted by a user with CONTROL permission on a database.
@@ -272,6 +281,16 @@ This example disables the identity cache.
272281
ALTER DATABASE SCOPED CONFIGURATION SET IDENTITY_CACHE=OFF ;
273282
```
274283

284+
### H. Set OPTIMIZE_FOR_AD_HOC_WORKLOADS
285+
286+
**Applies to**: [!INCLUDE[ssSDS](../../includes/sssds-md.md)]
287+
288+
This example enables a compiled plan stub to be stored in cache when a batch is compiled for the first time.
289+
290+
```sql
291+
ALTER DATABASE SCOPED CONFIGURATION SET OPTIMIZE_FOR_AD_HOC_WORKLOADS = ON;
292+
```
293+
275294
## Additional Resources
276295

277296
### MAXDOP Resources

0 commit comments

Comments
 (0)