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/relational-databases/statistics/statistics.md
+6-2Lines changed: 6 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: "Statistics | Microsoft Docs"
3
3
ms.custom: ""
4
-
ms.date: "12/18/2017"
4
+
ms.date: "06/03/2020"
5
5
ms.prod: sql
6
6
ms.reviewer: ""
7
7
ms.technology: performance
@@ -131,7 +131,11 @@ For more information about controlling AUTO_UPDATE_STATISTICS, see [Controlling
131
131
* Your application frequently executes the same query, similar queries, or similar cached query plans. Your query response times might be more predictable with asynchronous statistics updates than with synchronous statistics updates because the Query Optimizer can execute incoming queries without waiting for up-to-date statistics. This avoids delaying some queries and not others.
132
132
133
133
* Your application has experienced client request time outs caused by one or more queries waiting for updated statistics. In some cases, waiting for synchronous statistics could cause applications with aggressive time outs to fail.
134
-
134
+
135
+
Asynchronous statistics update is performed by a background request. When the request is ready to write updated statistics to the database, it attempts to acquire a schema modification lock on the statistics metadata object. If a different session is already holding a lock on the same object, asynchronous statistics update is blocked until the schema modification lock can be acquired. Similarly, sessions that need to acquire a schema stability lock on the statistics metadata object to compile a query may be blocked by the asynchronous statistics update background session, which is already holding or waiting to acquire the schema modification lock. Therefore, for workloads with very frequent query compilations and frequent statistics updates, using asynchronous statistics may increase the likelihood of concurrency issues due to lock blocking.
136
+
137
+
In Azure SQL Database, you can avoid potential concurrency issues using asynchronous statistics update if you enable the ASYNC_STATS_UPDATE_WAIT_AT_LOW_PRIORITY [database-scoped configuration](../../t-sql/statements/alter-database-scoped-configuration-transact-sql.md). With this configuration enabled, the background request will wait to acquire the schema modification lock on a separate low priority queue, allowing other requests to continue compiling queries with existing statistics. Once no other session is holding a lock on the statistics metadata object, the background request will acquire its schema modification lock and update statistics. In the unlikely event that the background request cannot acquire the lock within a timeout period of several minutes, the asynchronous statistics update will be aborted, and the statistics will not be updated until another automatic statistics update is triggered, or until statistics are [updated manually](update-statistics.md).
138
+
135
139
#### INCREMENTAL
136
140
When INCREMENTAL option of CREATE STATISTICS is ON, the statistics created are per partition statistics. When OFF, the statistics tree is dropped and [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] re-computes the statistics. The default is OFF. This setting overrides the database level INCREMENTAL property. For more information about creating incremental statistics, see [CREATE STATISTICS (Transact-SQL)](../../t-sql/statements/create-statistics-transact-sql.md). For more information about creating per partition statistics automatically, see [Database Properties (Options Page)](../../relational-databases/databases/database-properties-options-page.md#automatic) and [ALTER DATABASE SET Options (Transact-SQL)](../../t-sql/statements/alter-database-transact-sql-set-options.md).
This command enables several database configuration settings at the **individual database** level.
33
33
34
-
Following settings are supported in [!INCLUDE[sssdsfull](../../includes/sssdsfull-md.md)] and in [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)]beginning with [!INCLUDE[ssSQL15](../../includes/sssql15-md.md)]:
34
+
Following settings are supported in [!INCLUDE[sssdsfull](../../includes/sssdsfull-md.md)] and in [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)]as indicated by the **APPLIES TO** line for each setting in the [Arguments](#arguments) section:
35
35
36
36
- Clear procedure cache.
37
37
- Set the MAXDOP parameter to an arbitrary value (1,2, ...) for the primary database based on what works best for that particular database and set a different value (such as 0) for all secondary database used (such as for reporting queries).
@@ -50,6 +50,7 @@ Following settings are supported in [!INCLUDE[sssdsfull](../../includes/sssdsful
50
50
- Enable or disable the new `String or binary data would be truncated` error message.
51
51
- Enable or disable collection of last actual execution plan in [sys.dm_exec_query_plan_stats](../../relational-databases/system-dynamic-management-views/sys-dm-exec-query-plan-stats-transact-sql.md).
52
52
- Specify the number of minutes that a paused resumable index operation is paused before it is automatically aborted by the SQL Server engine.
53
+
- Enable or disable waiting for locks at low priority for asynchronous statistics update
53
54
54
55
This setting is only available in Azure Synapse Analytics (Formerly SQL DW).
55
56
- Set the compatibility level of a user database
@@ -95,6 +96,7 @@ ALTER DATABASE SCOPED CONFIGURATION
| ISOLATE_SECURITY_POLICY_CARDINALITY = { ON | OFF }
99
+
| ASYNC_STATS_UPDATE_WAIT_AT_LOW_PRIORITY = { ON | OFF }
98
100
}
99
101
```
100
102
@@ -104,8 +106,8 @@ ALTER DATABASE SCOPED CONFIGURATION
104
106
> -`DISABLE_BATCH_MODE_MEMORY_GRANT_FEEDBACK` changed to `BATCH_MODE_MEMORY_GRANT_FEEDBACK`
105
107
> -`DISABLE_BATCH_MODE_ADAPTIVE_JOINS` changed to `BATCH_MODE_ADAPTIVE_JOINS`
106
108
107
-
```syntaxsql
108
-
-- Synatx for Azure Synapse Analytics (Formerly SQL DW)
109
+
```SQL
110
+
--Syntax for Azure Synapse Analytics (Formerly SQL DW)
109
111
110
112
ALTERDATABASE SCOPED CONFIGURATION
111
113
{
@@ -404,6 +406,12 @@ Sets Transact-SQL and query processing behaviors to be compatible with the speci
404
406
|**10**| Exercises the Transact-SQL and query processing behaviors before the introduction of compatibility level support.|
405
407
|**20**| 1st compatibility level that includes gated Transact-SQL and query processing behaviors. |
406
408
409
+
ASYNC_STATS_UPDATE_WAIT_AT_LOW_PRIORITY **=** { ON | **OFF**}
410
+
411
+
**APPLIES TO**: Azure SQL Database only (feature is in public preview)
412
+
413
+
If asynchronous statistics update is enabled, enabling this configuration will cause the background request updating statistics to wait for a Sch-M lock on a low priority queue, to avoid blocking other sessions in high concurrency scenarios. For more information, see [AUTO_UPDATE_STATISTICS_ASYNC](../../relational-databases/statistics/statistics.md#auto_update_statistics_async).
414
+
407
415
## <aname="Permissions"></a> Permissions
408
416
409
417
Requires `ALTER ANY DATABASE SCOPED CONFIGURATION` on the database. This permission can be granted by a user with CONTROL permission on a database.
@@ -414,7 +422,7 @@ While you can configure secondary databases to have different scoped configurati
414
422
415
423
Executing this statement clears the procedure cache in the current database, which means that all queries have to recompile.
416
424
417
-
For 3-part name queries, the settings for the current database connection for the query are honored, other than for SQL modules (such as procedures, functions, and triggers) that are compiled in the current database context and therefore uses the options of the database in which they reside.
425
+
For 3-part name queries, the settings for the current database connection for the query are honored, other than for SQL modules (such as procedures, functions, and triggers) that are compiled in another database context and therefore use the options of the database in which they reside. Similarly, when updating statistics asynchronously, the setting of ASYNC_STATS_UPDATE_WAIT_AT_LOW_PRIORITY for the database where statistics reside is honored.
418
426
419
427
The `ALTER_DATABASE_SCOPED_CONFIGURATION` event is added as a DDL event that can be used to fire a DDL trigger, and is a child of the `ALTER_DATABASE_EVENTS` trigger group.
0 commit comments