You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/t-sql/statements/alter-database-scoped-configuration-transact-sql.md
+32-23Lines changed: 32 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,11 +38,11 @@ manager: "jhubbard"
38
38
39
39
- Set the query optimizer cardinality estimation model independent of the database to compatibility level.
40
40
41
-
- Enable or disable parameter sniffing at the database level.
41
+
- Enable or disable parameter sniffing at the database level.
42
42
43
-
- Enable or disable query optimization hotfixes at the database level.
43
+
- Enable or disable query optimization hotfixes at the database level.
44
44
45
-
- Enable or disable the identity cache at the database level.
45
+
- Enable or disable the identity cache at the database level.
46
46
47
47
[Transact-SQL Syntax Conventions](../../t-sql/language-elements/transact-sql-syntax-conventions-transact-sql.md)
48
48
@@ -81,37 +81,50 @@ Specifies the default MAXDOP setting that should be used for statements. 0 is th
81
81
82
82
You can use the max degree of parallelism option to limit the number of processors to use in parallel plan execution. SQL Server considers parallel execution plans for queries, index data definition language (DDL) operations, parallel insert, online alter column, parallel stats collectiion, and static and keyset-driven cursor population.
83
83
84
-
To set this option at the instance level, see [Configure the max degree of parallelism Server Configuration Option](../../database-engine/configure-windows/configure-the-max-degree-of-parallelism-server-configuration-option.md). To accomplish this at the query level, add the **QUERYTRACEON**[query hint](https://msdn.microsoft.com/library/ms181714.aspx)
84
+
To set this option at the instance level, see [Configure the max degree of parallelism Server Configuration Option](../../database-engine/configure-windows/configure-the-max-degree-of-parallelism-server-configuration-option.md).
85
+
86
+
> [!TIP]
87
+
> To accomplish this at the query level, add the **MAXDOP**[query hint](../../t-sql/queries/hints-transact-sql-query.md).
85
88
86
89
PRIMARY
87
90
88
-
Can only be set for the secondariesand indicates that the configuration will be the one set for the primary. If the configuration for the primary changes, secondary will also adjust to the same value. **PRIMARY** is the default setting for the secondaries
91
+
Can only be set for the secondaries, while the database in on the primary, and indicates that the configuration will be the one set for the primary. If the configuration for the primary changes, the value on the secondaries will change accordingly without the need to set the secondaries value explicitely. **PRIMARY** is the default setting for the secondaries.
89
92
90
93
LEGACY_CARDINALITY_ESTIMATION **=** { ON | **OFF** | PRIMARY }
91
94
92
-
Enables you to set the query optimizer cardinality estimation model to the SQL Server 2012 and earlier version independent of the compatibility level of the database. The default is **OFF**, which sets the query optimizer cardinality estimation model based on the compatibility level of the database. Setting this to **ON** is equivalent to [Trace Flag 9481](https://support.microsoft.com/en-us/kb/2801413). To set this at the instance level, see [Trace Flags (Transact-SQL)](../../t-sql/database-console-commands/dbcc-traceon-trace-flags-transact-sql.md). To accomplish this at the query level, add the **QUERYTRACEON**[query hint](https://msdn.microsoft.com/library/ms181714.aspx).
95
+
Enables you to set the query optimizer cardinality estimation model to the SQL Server 2012 and earlier version independent of the compatibility level of the database. The default is **OFF**, which sets the query optimizer cardinality estimation model based on the compatibility level of the database. Setting this to **ON** is equivalent to enabling [Trace Flag 9481](../../t-sql/database-console-commands/dbcc-traceon-trace-flags-transact-sql.md).
96
+
97
+
> [!TIP]
98
+
> To accomplish this at the query level, add the **QUERYTRACEON**[query hint](../../t-sql/database-console-commands/dbcc-traceon-trace-flags-transact-sql.md).
99
+
> Starting with [!INCLUDE[ssSQL15](../../includes/sssql15-md.md)] SP1, to accomplish this at the query level, add the **USE HINT**[query hint](../../t-sql/queries/hints-transact-sql-query.md) instead of using the trace flag.
93
100
94
101
PRIMARY
95
102
96
-
This value is only valid on secondaries and specifies that the query optimizer cardinality estimation model setting on all secondaries will be the value set for the primary. If the configuration on the primary for the query optimizer cardinality estimation model changes, the value on the secondaries will change accordingly. **PRIMARY** is the default setting for the secondaries.
103
+
This value is only valid on secondaries while the database in on the primary, and specifies that the query optimizer cardinality estimation model setting on all secondaries will be the value set for the primary. If the configuration on the primary for the query optimizer cardinality estimation model changes, the value on the secondaries will change accordingly. **PRIMARY** is the default setting for the secondaries.
97
104
98
105
PARAMETER_SNIFFING **=** { **ON** | OFF | PRIMARY}
99
106
100
-
Enables or disables parameter sniffing. The default is ON. This is equivalent to [Trace Flag 4136](https://support.microsoft.com/en-us/kb/980653). To set this at the instance level, see [Trace Flags (Transact-SQL)](../../t-sql/database-console-commands/dbcc-traceon-trace-flags-transact-sql.md). To set this at the query level, see the **OPTIMIZE FOR UNKNOWN**[query hint](https://msdn.microsoft.com/library/ms181714.aspx).
107
+
Enables or disables [parameter sniffing](../../relational-databases/query-processing-architecture-guide.md#ParamSniffing). The default is ON. This is equivalent to [Trace Flag 4136](../../t-sql/database-console-commands/dbcc-traceon-trace-flags-transact-sql.md).
108
+
109
+
> [!TIP]
110
+
> To accomplish this at the query level, see the **OPTIMIZE FOR UNKNOWN**[query hint](../../t-sql/queries/hints-transact-sql-query.md).
111
+
> Starting with [!INCLUDE[ssSQL15](../../includes/sssql15-md.md)] SP1, to accomplish this at the query level, the **USE HINT**[query hint](../../t-sql/queries/hints-transact-sql-query.md) is also available.
101
112
102
113
PRIMARY
103
114
104
-
This value is only valid on secondaries and specifies that the value for this setting on all secondaries will be the vale set for the primary. If the configuration for the primary changes, the value on the secondaries will change accordingly. This is the default setting for the secondaries.
115
+
This value is only valid on secondaries while the database in on the primary, and specifies that the value for this setting on all secondaries will be the value set for the primary. If the configuration on the primary for using [parameter sniffing](../../relational-databases/query-processing-architecture-guide.md#ParamSniffing)changes, the value on the secondaries will change accordingly without the need to set the secondaries value explicitely. This is the default setting for the secondaries.
105
116
106
117
QUERY_OPTIMIZER_HOTFIXES **=** { ON | **OFF** | PRIMARY }
107
118
108
-
Enables or disables query optimization hotfixes regardless of the compatibility level of the database. The default is **OFF**. This is equivalent to [Trace Flag 4199](https://support.microsoft.com/en-us/kb/974006).
119
+
Enables or disables query optimization hotfixes regardless of the compatibility level of the database. The default is **OFF**. This is equivalent to enabling [Trace Flag 4199](../../t-sql/database-console-commands/dbcc-traceon-trace-flags-transact-sql.md).
109
120
110
-
To set this at the instance level, see [Trace Flags (Transact-SQL)](../../t-sql/database-console-commands/dbcc-traceon-trace-flags-transact-sql.md). To accomplish this at the query level, add the **QUERYTRACEON**[query hint](https://msdn.microsoft.com/library/ms181714.aspx).
121
+
> [!TIP]
122
+
> To accomplish this at the query level, add the **QUERYTRACEON**[query hint](../../t-sql/database-console-commands/dbcc-traceon-trace-flags-transact-sql.md).
123
+
> Starting with [!INCLUDE[ssSQL15](../../includes/sssql15-md.md)] SP1, to accomplish this at the query level, add the USE HINT [query hint](../../t-sql/queries/hints-transact-sql-query.md) instead of using the trace flag.
111
124
112
125
PRIMARY
113
126
114
-
This value is only valid on secondaries and specifies that the value for this setting on all secondaries will be the vale set for the primary. If the configuration for the primary changes, the value on the secondaries will change accordingly. This is the default setting for the secondaries.
127
+
This value is only valid on secondaries while the database in on the primary, and specifies that the value for this setting on all secondaries will be the value set for the primary. If the configuration for the primary changes, the value on the secondaries will change accordingly without the need to set the secondaries value explicitely. This is the default setting for the secondaries.
115
128
116
129
CLEAR PROCEDURE_CACHE
117
130
@@ -165,7 +178,7 @@ on the database. This permission can be granted by a user with CONTROL permissio
165
178
166
179
**DacFx**
167
180
168
-
Since ALTER DATABASE SCOPED CONFIGURATION is a new feature in Azure SQL Database and SQL Server 2016 that affects the database schema, exports of the schema (with or without data) will not be able to be imported into an older version of SQL Server e.g. SQL Server 2012 or SQL Server 2014. For example, an export to a [DACPAC](https://msdn.microsoft.com/library/ee210546.aspx#Anchor_3) or a [BACPAC](https://msdn.microsoft.com/library/ee210546.aspx#Anchor_4) from an Azure SQL Database or SQL Server 2016 database that used this new feature would not be able to be imported into a down-level server.
181
+
Since ALTER DATABASE SCOPED CONFIGURATION is a new feature in Azure SQL Database and SQL Server 2016 that affects the database schema, exports of the schema (with or without data) will not be able to be imported into an older version of SQL Server e.g. [!INCLUDE[ssSQL11](../../includes/sssql11-md.md)]or [!INCLUDE[ssSQLv14](../../includes/sssqlv14-md.md)]. For example, an export to a [DACPAC](https://msdn.microsoft.com/library/ee210546.aspx#Anchor_3) or a [BACPAC](https://msdn.microsoft.com/library/ee210546.aspx#Anchor_4) from an [!INCLUDE[ssSDS](../../includes/sssds-md.md)]or [!INCLUDE[ssSQL15](../../includes/sssql15-md.md)] database that used this new feature would not be able to be imported into a down-level server.
169
182
170
183
## Metadata
171
184
@@ -192,26 +205,24 @@ ALTER DATABASE SCOPED CONFIGURATION SET MAXDOP = 1 ;
192
205
ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY SET MAXDOP=4 ;
193
206
```
194
207
195
-
This example sets MAXDOP for a secondary database as it is for its primary database in a geo-replication scenario.
208
+
This example sets MAXDOP for a secondary database to be the same as it is set for its primary database in a geo-replication scenario.
196
209
197
210
```tsql
198
-
ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY SET MAXDOP=PRIMARY
211
+
ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY SET MAXDOP=PRIMARY ;
199
212
```
200
213
201
214
### C. Set LEGACY_CARDINALITY_ESTIMATION
202
215
203
216
This example sets LEGACY_CARDINALITY_ESTIMATION to ON for a secondary database in a geo-replication scenario.
204
217
205
218
```tsql
206
-
ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY
207
-
SET LEGACY_CARDINALITY_ESTIMATION=ON ;
219
+
ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY SET LEGACY_CARDINALITY_ESTIMATION=ON ;
208
220
```
209
221
210
222
This example sets LEGACY_CARDINALITY_ESTIMATION for a secondary database as it is for its primary database in a geo-replication scenario.
211
223
212
224
```tsql
213
-
ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY
214
-
SET LEGACY_CARDINALITY_ESTIMATION=PRIMARY ;
225
+
ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY SET LEGACY_CARDINALITY_ESTIMATION=PRIMARY ;
215
226
```
216
227
217
228
### D. Set PARAMETER_SNIFFING
@@ -225,16 +236,14 @@ ALTER DATABASE SCOPED CONFIGURATION SET PARAMETER_SNIFFING =OFF ;
225
236
This example sets PARAMETER_SNIFFING to OFF for a primary database in a geo-replication scenario.
226
237
227
238
```tsql
228
-
ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY
229
-
SET PARAMETER_SNIFFING=OFF ;
239
+
ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY SET PARAMETER_SNIFFING=OFF ;
230
240
```
231
241
232
242
This example sets PARAMETER_SNIFFING for secondary database as it is on primary database
233
243
in a geo-replication scenario.
234
244
235
245
```tsql
236
-
ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY
237
-
SET PARAMETER_SNIFFING =PRIMARY ;
246
+
ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY SET PARAMETER_SNIFFING =PRIMARY ;
0 commit comments