Skip to content

Commit 476f169

Browse files
authored
Add TVDC disable instructions
Add TVDC disable instructions
1 parent 5ce9534 commit 476f169

1 file changed

Lines changed: 39 additions & 1 deletion

File tree

docs/t-sql/data-types/table-transact-sql.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "table (Transact-SQL) | Microsoft Docs"
33
ms.custom: ""
4-
ms.date: "7/24/2018"
4+
ms.date: "10/11/2018"
55
ms.prod: sql
66
ms.prod_service: "database-engine, sql-database"
77
ms.reviewer: ""
@@ -122,6 +122,44 @@ Table variable deferred compilation **does not increase recompilation frequency*
122122

123123
If the table variable row count used for initial plan compilation represents a typical value that is significantly different from a fixed row count guess, downstream operations will benefit. If the table variable row count varies significantly across executions, then performance may not be improved by this feature.
124124

125+
### Disabling table variable deferred compilation without changing the compatibility level
126+
Table variable deferred compilation can be disabled at the database or statement scope while still maintaining database compatibility level 150 and higher. To disable table variable deferred compilation for all query executions originating from the database, execute the following within the context of the applicable database:
127+
128+
```sql
129+
ALTER DATABASE SCOPED CONFIGURATION SET DEFERRED_COMPILATION_TV = OFF;
130+
```
131+
132+
To re-enable table variable deferred compilation for all query executions originating from the database, execute the following within the context of the applicable database:
133+
134+
```sql
135+
ALTER DATABASE SCOPED CONFIGURATION SET DEFERRED_COMPILATION_TV = ON;
136+
```
137+
138+
You can also disable table variable deferred compilation for a specific query by designating DISABLE_DEFERRED_COMPILATION_TV as a USE HINT query hint. For example:
139+
140+
```sql
141+
DECLARE @LINEITEMS TABLE
142+
(L_OrderKey INT NOT NULL,
143+
L_Quantity INT NOT NULL
144+
);
145+
146+
INSERT @LINEITEMS
147+
SELECT L_OrderKey, L_Quantity
148+
FROM dbo.lineitem
149+
WHERE L_Quantity = 5;
150+
151+
SELECT O_OrderKey,
152+
O_CustKey,
153+
O_OrderStatus,
154+
L_QUANTITY
155+
FROM
156+
ORDERS,
157+
@LINEITEMS
158+
WHERE O_ORDERKEY = L_ORDERKEY
159+
AND O_OrderStatus = 'O'
160+
OPTION (USE HINT('DISABLE_DEFERRED_COMPILATION_TV'));
161+
```
162+
125163

126164
## Examples
127165

0 commit comments

Comments
 (0)