Skip to content

Commit 6fc3e59

Browse files
authored
Merge pull request #4456 from pmasl/patch-98
Update create-statistics-transact-sql.md
2 parents da5813c + 04d7d35 commit 6fc3e59

1 file changed

Lines changed: 37 additions & 16 deletions

File tree

docs/t-sql/statements/create-statistics-transact-sql.md

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "CREATE STATISTICS (Transact-SQL) | Microsoft Docs"
33
ms.custom: ""
4-
ms.date: "08/10/2017"
4+
ms.date: "01/04/2018"
55
ms.prod: "sql-non-specified"
66
ms.prod_service: "database-engine, sql-database, sql-data-warehouse, pdw"
77
ms.service: ""
@@ -62,9 +62,10 @@ ON { table_or_indexed_view_name } ( column [ ,...n ] )
6262
[ [ , ] PERSIST_SAMPLE_PERCENT = { ON | OFF } ]
6363
| SAMPLE number { PERCENT | ROWS }
6464
           [ [ , ] PERSIST_SAMPLE_PERCENT = { ON | OFF } ]    
65-
| STATS_STREAM = stats_stream ] ]
65+
| <update_stats_stream_option> [ ,...n ]
6666
[ [ , ] NORECOMPUTE ]
67-
[ [ , ] INCREMENTAL = { ON | OFF } ]
67+
[ [ , ] INCREMENTAL = { ON | OFF } ]
68+
[ [ , ] MAXDOP = max_degree_of_parallelism ]
6869
] ;
6970
7071
<filter_predicate> ::=
@@ -81,6 +82,11 @@ ON { table_or_indexed_view_name } ( column [ ,...n ] )
8182
8283
<comparison_op> ::=
8384
IS | IS NOT | = | <> | != | > | >= | !> | < | <= | !<
85+
86+
<update_stats_stream_option> ::=
87+
[ STATS_STREAM = stats_stream ]
88+
[ ROWCOUNT = numeric_constant ]
89+
[ PAGECOUNT = numeric_contant ]
8490
```
8591

8692
```
@@ -136,11 +142,11 @@ CREATE STATISTICS statistics_name
136142

137143
Here are some examples of filter predicates for the Production.BillOfMaterials table:
138144

139-
`WHERE StartDate > '20000101' AND EndDate <= '20000630'`
145+
* `WHERE StartDate > '20000101' AND EndDate <= '20000630'`
140146

141-
`WHERE ComponentID IN (533, 324, 753)`
147+
* `WHERE ComponentID IN (533, 324, 753)`
142148

143-
`WHERE StartDate IN ('20000404', '20000905') AND EndDate IS NOT NULL`
149+
* `WHERE StartDate IN ('20000404', '20000905') AND EndDate IS NOT NULL`
144150

145151
For more information about filter predicates, see [Create Filtered Indexes](../../relational-databases/indexes/create-filtered-indexes.md).
146152

@@ -182,28 +188,42 @@ CREATE STATISTICS statistics_name
182188
If per partition statistics are not supported an error is generated. Incremental stats are not supported for following statistics types:
183189

184190
- Statistics created with indexes that are not partition-aligned with the base table.
185-
186191
- Statistics created on Always On readable secondary databases.
187-
188192
- Statistics created on read-only databases.
189-
190193
- Statistics created on filtered indexes.
191-
192194
- Statistics created on views.
193-
194195
- Statistics created on internal tables.
195-
196196
- Statistics created with spatial indexes or XML indexes.
197197

198198
**Applies to**: [!INCLUDE[ssSQL14](../../includes/sssql14-md.md)] through [!INCLUDE[ssCurrent](../../includes/sscurrent-md.md)].
199199

200+
MAXDOP = *max_degree_of_parallelism*
201+
**Applies to**: [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] (Starting with [!INCLUDE[ssSQL17](../../includes/sssql17-md.md)] CU3).
202+
203+
Overrides the **max degree of parallelism** configuration option for the duration of the statistic operation. For more information, see [Configure the max degree of parallelism Server Configuration Option](../../database-engine/configure-windows/configure-the-max-degree-of-parallelism-server-configuration-option.md). Use MAXDOP to limit the number of processors used in a parallel plan execution. The maximum is 64 processors.
204+
205+
*max_degree_of_parallelism* can be:
206+
207+
1
208+
Suppresses parallel plan generation.
209+
210+
\>1
211+
Restricts the maximum number of processors used in a parallel statistic operation to the specified number or fewer based on the current system workload.
212+
213+
0 (default)
214+
Uses the actual number of processors or fewer based on the current system workload.
215+
216+
> [!NOTE]
217+
> Parallel statistics operations are not available in every edition of [!INCLUDE[msCoName](../../includes/msconame-md.md)][!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)]. For a list of features that are supported by the editions of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)], see [Editions and Supported Features for SQL Server 2016](../../sql-server/editions-and-supported-features-for-sql-server-2016.md) and [Editions and Supported Features for SQL Server 2017](../../sql-server/editions-and-components-of-sql-server-2017.md).
218+
219+
\<update_stats_stream_option>
220+
[!INCLUDE[ssInternalOnly](../../includes/ssinternalonly-md.md)]
221+
200222
## Permissions
201223
Requires one of these permissions:
202224

203225
- ALTER TABLE
204-
205226
- User is the table owner
206-
207227
- Membership in the **db_ddladmin** fixed database role
208228

209229
## General Remarks
@@ -222,8 +242,9 @@ CREATE STATISTICS statistics_name
222242
The [sys.sql_expression_dependencies](../../relational-databases/system-catalog-views/sys-sql-expression-dependencies-transact-sql.md) catalog view tracks each column in the filtered statistics predicate as a referencing dependency. Consider the operations that you perform on table columns before creating filtered statistics because you cannot drop, rename, or alter the definition of a table column that is defined in a filtered statistics predicate.
223243

224244
## Limitations and Restrictions
225-
* Updating statistics is not supported on external tables. To update statistics on an external table, drop and re-create the statistics.
226-
* You can list up to 64 columns per statistics object.
245+
* Updating statistics is not supported on external tables. To update statistics on an external table, drop and re-create the statistics.
246+
* You can list up to 64 columns per statistics object.
247+
* The MAXDOP option is not compatible with STATS_STREAM, ROWCOUNT and PAGECOUNT options.
227248

228249
## Examples
229250

0 commit comments

Comments
 (0)