Skip to content

Commit cab174b

Browse files
Merge pull request #34668 from WilliamDAssafMSFT/20250709-kill-permissions-fabric-dw
20250710 fabric dw permissions
2 parents fd92605 + 68eddaa commit cab174b

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

docs/t-sql/database-console-commands/dbcc-show-statistics-transact-sql.md

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: "DBCC SHOW_STATISTICS (Transact-SQL)"
33
description: DBCC SHOW_STATISTICS displays current query optimization statistics for a table or indexed view.
44
author: rwestMSFT
55
ms.author: randolphwest
6-
ms.date: 08/29/2023
6+
ms.date: 07/10/2025
77
ms.service: sql
88
ms.subservice: t-sql
99
ms.topic: reference
@@ -91,7 +91,7 @@ Name of the table that contains the statistics to display. The table can't be an
9191
Name of the index, statistics, or column for which to display statistics information. *target* is enclosed in brackets, single quotes, double quotes, or no quotes.
9292

9393
- If *target* is a name of an existing index or statistics on a table or indexed view, the statistics information about this target is returned.
94-
- If *target* is the name of an existing column, and an automatically created statistics object on this column exists, information about that auto-created statistic is returned.
94+
- If *target* is the name of an existing column, and an automatically created statistics object on this column exists, information about that autocreated statistic is returned.
9595

9696
If an automatically created statistic doesn't exist for a column target, error message 2767 is returned.
9797

@@ -116,38 +116,38 @@ The following table describes the columns returned in the result set when STAT_H
116116
| Column name | Description |
117117
| --- | --- |
118118
| Name | Name of the statistics object. |
119-
| Updated | Date and time the statistics were last updated. The [STATS_DATE](../../t-sql/functions/stats-date-transact-sql.md) function is an alternate way to retrieve this information. For more information, see the [Remarks](#remarks) section in this page. |
119+
| Updated | Date and time the statistics were last updated. The [STATS_DATE](../functions/stats-date-transact-sql.md) function is an alternate way to retrieve this information. For more information, see the [Remarks](#remarks) section in this page. |
120120
| Rows | Total number of rows in the table or indexed view when the statistics were last updated. If the statistics are filtered or correspond to a filtered index, the number of rows might be less than the number of rows in the table. For more information, see [Statistics](../../relational-databases/statistics/statistics.md). |
121121
| Rows Sampled | Total number of rows sampled for statistics calculations. If Rows Sampled < Rows, the displayed histogram and density results are estimates based on the sampled rows. |
122122
| Steps | Number of steps in the histogram. Each step spans a range of column values followed by an upper bound column value. The histogram steps are defined on the first key column in the statistics. The maximum number of steps is 200. |
123123
| Density | Calculated as 1 / *distinct values* for all values in the first key column of the statistics object, excluding the histogram boundary values. This Density value isn't used by the Query Optimizer and is displayed for backward compatibility with versions before [!INCLUDE [sql2008-md](../../includes/sql2008-md.md)]. |
124124
| Average Key Length | Average number of bytes per value for all of the key columns in the statistics object. |
125125
| String Index | Yes indicates the statistics object contains string summary statistics to improve the cardinality estimates for query predicates that use the LIKE operator; for example, `WHERE ProductName LIKE '%Bike'`. String summary statistics are stored separately from the histogram and are created on the first key column of the statistics object when it's of type **char**, **varchar**, **nchar**, **nvarchar**, **varchar(max)**, **nvarchar(max)**, **text**, or **ntext.**. |
126-
| Filter Expression | Predicate for the subset of table rows included in the statistics object. `NULL` = non-filtered statistics. For more information about filtered predicates, see [Create Filtered Indexes](../../relational-databases/indexes/create-filtered-indexes.md). For more information about filtered statistics, see [Statistics](../../relational-databases/statistics/statistics.md). |
126+
| Filter Expression | Predicate for the subset of table rows included in the statistics object. `NULL` = non-filtered statistics. For more information about filtered predicates, see [Create filtered indexes](../../relational-databases/indexes/create-filtered-indexes.md). For more information about filtered statistics, see [Statistics](../../relational-databases/statistics/statistics.md). |
127127
| Unfiltered Rows | Total number of rows in the table before applying the filter expression. If Filter Expression is `NULL`, `Unfiltered Rows` is equal to `Rows`. |
128128
| Persisted Sample Percent | Persisted sample percentage used for statistic updates that don't explicitly specify a sampling percentage. If value is zero, then no persisted sample percentage is set for this statistic.<br /><br />**Applies to:** [!INCLUDE [sssql16-md](../../includes/sssql16-md.md)] Service Pack 1 CU 4 |
129129

130-
The following table describes the columns returned in the result set when DENSITY_VECTOR is specified.
130+
The following table describes the columns returned in the result set when `DENSITY_VECTOR` is specified.
131131

132132
| Column name | Description |
133133
| --- | --- |
134134
| All Density | Density is 1 / *distinct values*. Results display density for each prefix of columns in the statistics object, one row per density. A distinct value is a distinct list of the column values per row and per columns prefix. For example, if the statistics object contains key columns (A, B, C), the results report the density of the distinct lists of values in each of these column prefixes: (A), (A,B), and (A, B, C). Using the prefix (A, B, C), each of these lists is a distinct value list: (3, 5, 6), (4, 4, 6), (4, 5, 6), (4, 5, 7). Using the prefix (A, B) the same column values have these distinct value lists: (3, 5), (4, 4), and (4, 5) |
135135
| Average Length | Average length, in bytes, to store a list of the column values for the column prefix. For example, if the values in the list (3, 5, 6) each require 4 bytes the length is 12 bytes. |
136136
| Columns | Names of columns in the prefix for which All density and Average length are displayed. |
137137

138-
The following table describes the columns returned in the result set when the HISTOGRAM option is specified.
138+
The following table describes the columns returned in the result set when the `HISTOGRAM` option is specified.
139139

140140
| Column name | Description |
141141
| --- | --- |
142-
| RANGE_HI_KEY | Upper bound column value for a histogram step. The column value is also called a key value. |
143-
| RANGE_ROWS | Estimated number of rows whose column value falls within a histogram step, excluding the upper bound. |
144-
| EQ_ROWS | Estimated number of rows whose column value equals the upper bound of the histogram step. |
145-
| DISTINCT_RANGE_ROWS | Estimated number of rows with a distinct column value within a histogram step, excluding the upper bound. |
146-
| AVG_RANGE_ROWS | Average number of rows with duplicate column values within a histogram step, excluding the upper bound. When DISTINCT_RANGE_ROWS is greater than 0, AVG_RANGE_ROWS is calculated by dividing RANGE_ROWS by DISTINCT_RANGE_ROWS. When DISTINCT_RANGE_ROWS is 0, AVG_RANGE_ROWS returns 1 for the histogram step. |
142+
| `RANGE_HI_KEY` | Upper bound column value for a histogram step. The column value is also called a key value. |
143+
| `RANGE_ROWS` | Estimated number of rows whose column value falls within a histogram step, excluding the upper bound. |
144+
| `EQ_ROWS` | Estimated number of rows whose column value equals the upper bound of the histogram step. |
145+
| `DISTINCT_RANGE_ROWS` | Estimated number of rows with a distinct column value within a histogram step, excluding the upper bound. |
146+
| `AVG_RANGE_ROWS` | Average number of rows with duplicate column values within a histogram step, excluding the upper bound. When `DISTINCT_RANGE_ROWS` is greater than 0, `AVG_RANGE_ROWS` is calculated by dividing `RANGE_ROWS` by `DISTINCT_RANGE_ROWS`. When `DISTINCT_RANGE_ROWS` is 0, `AVG_RANGE_ROWS` returns 1 for the histogram step. |
147147

148148
## Remarks
149149

150-
Statistics update date is stored in the [statistics blob object](../../relational-databases/statistics/statistics.md#DefinitionQOStatistics) together with the [histogram](#histogram) and [density vector](#density), not in the metadata. When no data is read to generate statistics data, the statistics blob isn't created, the date isn't available, and the *updated* column is `NULL`. This is the case for filtered statistics for which the predicate doesn't return any rows, or for new empty tables.
150+
Statistics update date is stored in the [statistics blob object](../../relational-databases/statistics/statistics.md#DefinitionQOStatistics) together with the [histogram](#histogram) and [density vector](#density), not in the metadata. When no data is read to generate statistics data, the statistics blob isn't created, the date isn't available, and the `updated` column is `NULL`. This is the case for filtered statistics for which the predicate doesn't return any rows, or for new empty tables.
151151

152152
## Histogram
153153

@@ -167,7 +167,9 @@ For each histogram step:
167167

168168
The query optimizer defines the histogram steps according to their statistical significance. It uses a maximum difference algorithm to minimize the number of steps in the histogram while maximizing the difference between the boundary values. The maximum number of steps is 200. The number of histogram steps can be fewer than the number of distinct values, even for columns with fewer than 200 boundary points. For example, a column with 100 distinct values can have a histogram with fewer than 100 boundary points.
169169

170-
## <a id="density"></a> Density vector
170+
<a id="density"></a>
171+
172+
## Density vector
171173

172174
The query optimizer uses densities to enhance cardinality estimates for queries that return multiple columns from the same table or indexed view. The density vector contains one density for each prefix of columns in the statistics object. For example, if a statistics object has the key columns `CustomerId`, `ItemId` and `Price`, density is calculated on each of the following column prefixes.
173175

@@ -185,29 +187,30 @@ The query optimizer uses densities to enhance cardinality estimates for queries
185187

186188
In order to view the statistics object, the user must have the `SELECT` permission on the table.
187189

188-
The following requirements exist for SELECT permissions to be sufficient to run the command:
190+
The following requirements exist for `SELECT` permissions to be sufficient to run the command:
189191

190-
- Users must have permissions on all columns in the statistics object
191-
- Users must have permission on all columns in a filter condition (if one exists)
192+
- Users must have permissions on all columns in the statistics object.
193+
- Users must have permission on all columns in a filter condition (if one exists).
192194
- The table can't have a row-level security policy.
193195
- If any of the columns within a statistics object is masked with Dynamic Data Masking rules, in addition to the `SELECT` permission, the user must have the `UNMASK` permission, or be a member of the **db_ddladmin** role.
194196

195-
In versions before [!INCLUDE [ssSQL11](../../includes/sssql11-md.md)] Service Pack 1, the user must own the table or the user must be a member of the **sysadmin** fixed server role, the **db_owner** fixed database role, or the **db_ddladmin** fixed database role.
197+
In versions before [!INCLUDE [ssSQL11](../../includes/sssql11-md.md)] Service Pack 1, the user must own the table or the user must be a member of the **sysadmin** fixed server role, the **db_owner** fixed database role, or the **db_ddladmin** fixed database role. To change the behavior back to the pre [!INCLUDE [ssSQL11](../../includes/sssql11-md.md)] Service Pack 1 behavior, use Trace Flag 9485.
198+
199+
## Permissions for [!INCLUDE [fabric](../../includes/fabric.md)] Data Warehouse and [!INCLUDE [fabric-se](../../includes/fabric-se.md)]
196200

197-
> [!NOTE]
198-
> To change the behavior back to the pre [!INCLUDE [ssSQL11](../../includes/sssql11-md.md)] Service Pack 1 behavior, use Trace Flag 9485.
201+
In order to view the statistics object in Fabric Data Warehouse or the SQL analytics endpoint, the user must have the `SELECT` permission on the table, or a member of the Viewer Fabric workspace role or higher role membership.
199202

200203
## Permissions for [!INCLUDE [ssazuresynapse-md](../../includes/ssazuresynapse-md.md)] and [!INCLUDE [ssPDW](../../includes/sspdw-md.md)]
201204

202205
`DBCC SHOW_STATISTICS` requires `SELECT` permission on the table or membership in the **sysadmin** fixed server role, the **db_owner** fixed database role, or the **db_ddladmin** fixed database role.
203206

204207
## Limitations and Restrictions for [!INCLUDE [ssazuresynapse-md](../../includes/ssazuresynapse-md.md)] and [!INCLUDE [ssPDW](../../includes/sspdw-md.md)]
205208

206-
`DBCC SHOW_STATISTICS` shows statistics stored in the `Shell` database at the Control node level. It doesn't show statistics that are auto-created by [!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)] on the Compute nodes.
209+
`DBCC SHOW_STATISTICS` shows statistics stored in the `Shell` database at the Control node level. It doesn't show statistics that are autocreated by [!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)] on the Compute nodes.
207210

208211
`DBCC SHOW_STATISTICS` isn't supported on external tables.
209212

210-
In [!INCLUDE [fabric](../../includes/fabric.md)], `DBCC SHOW_STATISTICS` only shows results for histogram statistics, not ACE-* statistics.
213+
In [!INCLUDE [fabric](../../includes/fabric.md)], `DBCC SHOW_STATISTICS` only shows results for histogram statistics, not `ACE-*` statistics.
211214

212215
## Examples: SQL Server and Azure SQL Database
213216

@@ -247,22 +250,19 @@ GO
247250

248251
The results show the header, the density vector, and part of the histogram.
249252

250-
:::image type="content" source="media/dbcc-show-statistics-transact-sql/dbcc-show-statistics.png" alt-text="Screenshot showing DBCC SHOW_STATISTICS results.":::
253+
:::image type="content" source="media/dbcc-show-statistics-transact-sql/dbcc-show-statistics.png" alt-text="Screenshot showing DBCC SHOW_STATISTICS results." lightbox="media/dbcc-show-statistics-transact-sql/dbcc-show-statistics.png":::
251254

252-
## See also
255+
## Related content
253256

254257
- [Statistics](../../relational-databases/statistics/statistics.md)
255-
- [Statistics in Microsoft Fabric](/fabric/data-warehouse/statistics)
258+
- [Statistics in Microsoft Fabric Data Warehouse](/fabric/data-warehouse/statistics)
256259
- [sys.dm_db_stats_properties (Transact-SQL)](../../relational-databases/system-dynamic-management-views/sys-dm-db-stats-properties-transact-sql.md)
257260
- [sys.dm_db_stats_histogram (Transact-SQL)](../../relational-databases/system-dynamic-management-views/sys-dm-db-stats-histogram-transact-sql.md)
258261
- [sys.dm_db_incremental_stats_properties (Transact-SQL)](../../relational-databases/system-dynamic-management-views/sys-dm-db-incremental-stats-properties-transact-sql.md)
259-
260-
## Next steps
261-
262-
- [CREATE INDEX (Transact-SQL)](../../t-sql/statements/create-index-transact-sql.md)
263-
- [CREATE STATISTICS (Transact-SQL)](../../t-sql/statements/create-statistics-transact-sql.md)
264-
- [DROP STATISTICS (Transact-SQL)](../../t-sql/statements/drop-statistics-transact-sql.md)
262+
- [CREATE INDEX (Transact-SQL)](../statements/create-index-transact-sql.md)
263+
- [CREATE STATISTICS (Transact-SQL)](../statements/create-statistics-transact-sql.md)
264+
- [DROP STATISTICS (Transact-SQL)](../statements/drop-statistics-transact-sql.md)
265265
- [sp_autostats (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-autostats-transact-sql.md)
266266
- [sp_createstats (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-createstats-transact-sql.md)
267-
- [STATS_DATE (Transact-SQL)](../../t-sql/functions/stats-date-transact-sql.md)
268-
- [UPDATE STATISTICS (Transact-SQL)](../../t-sql/statements/update-statistics-transact-sql.md)
267+
- [STATS_DATE (Transact-SQL)](../functions/stats-date-transact-sql.md)
268+
- [UPDATE STATISTICS (Transact-SQL)](../statements/update-statistics-transact-sql.md)

0 commit comments

Comments
 (0)