Skip to content

Commit ad7ec93

Browse files
Update sys.column_store_row_groups (#36165)
1 parent 20a2157 commit ad7ec93

1 file changed

Lines changed: 74 additions & 62 deletions

File tree

docs/relational-databases/system-catalog-views/sys-column-store-row-groups-transact-sql.md

Lines changed: 74 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ title: "sys.column_store_row_groups (Transact-SQL)"
33
description: sys.column_store_row_groups (Transact-SQL)
44
author: rwestMSFT
55
ms.author: randolphwest
6-
ms.date: "10/28/2020"
6+
ms.reviewer: dfurman
7+
ms.date: 01/05/2026
78
ms.service: sql
89
ms.subservice: system-objects
910
ms.topic: "reference"
@@ -18,66 +19,77 @@ helpviewer_keywords:
1819
dev_langs:
1920
- "TSQL"
2021
---
22+
2123
# sys.column_store_row_groups (Transact-SQL)
22-
[!INCLUDE[SQL Server 2012 Azure SQL Managed Instance](../../includes/applies-to-version/sqlserver2012-asdbmi.md)]
23-
24-
Provides clustered columnstore index information on a per-segment basis to help the administrator make system management decisions. **sys.column_store_row_groups** has a column for the total number of rows physically stored (including those marked as deleted) and a column for the number of rows marked as deleted. Use **sys.column_store_row_groups** to determine which row groups have a high percentage of deleted rows and should be rebuilt.
25-
26-
|Column name|Data type|Description|
27-
|-----------------|---------------|-----------------|
28-
|**object_id**|int|The id of the table on which this index is defined.|
29-
|**index_id**|int|ID of the index for the table that has this columnstore index.|
30-
|**partition_number**|int|ID of the table partition that holds row group row_group_id. You can use partition_number to join this DMV to sys.partitions.|
31-
|**row_group_id**|int|The row group number associated with this row group. This is unique within the partition.<br /><br /> -1 = tail of an in-memory table.|
32-
|**delta_store_hobt_id**|bigint|The hobt_id for OPEN row group in the delta store.<br /><br /> NULL if the row group is not in the delta store.<br /><br /> NULL for the tail of an in-memory table.|
33-
|**state**|tinyint|ID number associated with the state_description.<br /><br /> 0 = INVISIBLE<br /><br /> 1 = OPEN<br /><br /> 2 = CLOSED<br /><br /> 3 = COMPRESSED <br /><br /> 4 = TOMBSTONE|
34-
|**state_description**|nvarchar(60)|Description of the persistent state of the row group:<br /><br /> INVISIBLE -A hidden compressed segment in the process of being built from data in a delta store. Read actions will use the delta store until the invisible compressed segment is completed. Then the new segment is made visible, and the source delta store is removed.<br /><br /> OPEN - A read/write row group that is accepting new records. An open row group is still in rowstore format and has not been compressed to columnstore format.<br /><br /> CLOSED - A row group that has been filled, but not yet compressed by the tuple mover process.<br /><br /> COMPRESSED - A row group that has filled and compressed.|
35-
|**total_rows**|bigint|Total rows physically stored in the row group. Some may have been deleted but they are still stored. The maximum number of rows in a row group is 1,048,576 (hexadecimal FFFFF).|
36-
|**deleted_rows**|bigint|Total rows in the row group marked deleted. This is always 0 for DELTA row groups.|
37-
|**size_in_bytes**|bigint|Size in bytes of all the data in this row group (not including metadata or shared dictionaries), for both DELTA and COLUMNSTORE rowgroups.|
38-
39-
## Remarks
40-
Returns one row for each columnstore row group for each table having a clustered or nonclustered columnstore index.
41-
42-
Use **sys.column_store_row_groups** to determine the number of rows included in the row group and the size of the row group.
43-
44-
When the number of deleted rows in a row group grows to a large percentage of the total rows, the table becomes less efficient. Rebuild the columnstore index to reduce the size of the table, reducing the disk I/O required to read the table. To rebuild the columnstore index use the **REBUILD** option of the **ALTER INDEX** statement.
45-
46-
The updateable columnstore first inserts new data into an **OPEN** rowgroup, which is in rowstore format, and is also sometimes referred to as a delta table. Once an open rowgroup is full, its state changes to **CLOSED**. A closed rowgroup is compressed into columnstore format by the tuple mover and the state changes to **COMPRESSED**. The tuple mover is a background process that periodically wakes up and checks whether there are any closed rowgroups that are ready to compress into a columnstore rowgroup. The tuple mover also deallocates any rowgroups in which every row has been deleted. Deallocated rowgroups are marked as **TOMBSTONE**. To run tuple mover immediately, use the **REORGANIZE** option of the **ALTER INDEX** statement.
47-
48-
When a columnstore row group has filled, it is compressed, and stops accepting new rows. When rows are deleted from a compressed group, they remain but are marked as deleted. Updates to a compressed group are implemented as a delete from the compressed group, and an insert to an open group.
49-
50-
## Permissions
51-
Returns information for a table if the user has `VIEW DEFINITION` permission on the table.
52-
53-
[!INCLUDE[ssCatViewPerm](../../includes/sscatviewperm-md.md)] For more information, see [Metadata Visibility Configuration](../../relational-databases/security/metadata-visibility-configuration.md).
54-
55-
## Examples
56-
The following example joins the **sys.column_store_row_groups** table to other system tables to return information about specific tables. The calculated `PercentFull` column is an estimate of the efficiency of the row group. To find information on a single table remove the comment hyphens in front of the **WHERE** clause and provide a table name.
57-
58-
```sql
59-
SELECT i.object_id, object_name(i.object_id) AS TableName,
60-
i.name AS IndexName, i.index_id, i.type_desc,
61-
CSRowGroups.*,
62-
100*(total_rows - ISNULL(deleted_rows,0))/total_rows AS PercentFull
63-
FROM sys.indexes AS i
64-
JOIN sys.column_store_row_groups AS CSRowGroups
65-
ON i.object_id = CSRowGroups.object_id
66-
AND i.index_id = CSRowGroups.index_id
67-
--WHERE object_name(i.object_id) = '<table_name>'
68-
ORDER BY object_name(i.object_id), i.name, row_group_id;
69-
```
70-
71-
## See also
72-
[Object Catalog Views &#40;Transact-SQL&#41;](../../relational-databases/system-catalog-views/object-catalog-views-transact-sql.md)
73-
[Catalog Views &#40;Transact-SQL&#41;](../../relational-databases/system-catalog-views/catalog-views-transact-sql.md)
74-
[Querying the SQL Server System Catalog FAQ](../../relational-databases/system-catalog-views/querying-the-sql-server-system-catalog-faq.yml)
75-
[sys.columns &#40;Transact-SQL&#41;](../../relational-databases/system-catalog-views/sys-columns-transact-sql.md)
76-
[sys.all_columns &#40;Transact-SQL&#41;](../../relational-databases/system-catalog-views/sys-all-columns-transact-sql.md)
77-
[sys.computed_columns &#40;Transact-SQL&#41;](../../relational-databases/system-catalog-views/sys-computed-columns-transact-sql.md)
78-
[Columnstore Indexes Guide](~/relational-databases/indexes/columnstore-indexes-overview.md)
79-
[sys.column_store_dictionaries &#40;Transact-SQL&#41;](../../relational-databases/system-catalog-views/sys-column-store-dictionaries-transact-sql.md)
80-
[sys.column_store_segments &#40;Transact-SQL&#41;](../../relational-databases/system-catalog-views/sys-column-store-segments-transact-sql.md)
81-
82-
8324

25+
[!INCLUDE [sql-asdb-asdbmi-fabricsqldb](../../includes/applies-to-version/sql-asdb-asdbmi-fabricsqldb.md)]
26+
27+
Provides columnstore index information on a per-segment basis.
28+
29+
For clustered columnstore indexes, `sys.column_store_row_groups` has a column for the total number of rows physically stored (including those marked as deleted) and a column for the number of rows marked as deleted. Use `sys.column_store_row_groups` to determine which row groups have a high percentage of deleted rows and should be rebuilt.
30+
31+
| Column name | Data type | Description |
32+
| --- | --- | --- |
33+
| `object_id` | **int** | The ID of the table on which this index is defined. |
34+
| `index_id` | **int** | The ID of the columnstore index. |
35+
| `partition_number` | **int** | The table partition that holds the row group identified by `row_group_id`. Use `partition_number` to join `sys.partitions`. |
36+
| `row_group_id` | **int** | The row group number associated with this row group. This number is unique within the partition.<br /><br />-1 = tail of a memory-optimized table. |
37+
| `delta_store_hobt_id` | **bigint** | The `hobt_id` for an `OPEN` row group in the delta store.<br /><br />NULL if the row group isn't in the delta store.<br /><br />NULL for the tail of a memory-optimized table. |
38+
| `state` | **tinyint** | A number describing the row group state.<br /><br />0 = `INVISIBLE`<br /><br />1 = `OPEN`<br /><br />2 = `CLOSED`<br /><br />3 = `COMPRESSED`<br /><br />4 = `TOMBSTONE` |
39+
| `state_description` | **nvarchar(60)** | Description of the state of the row group:<br /><br />`INVISIBLE` - A hidden compressed segment in the process of being built from data in a delta store. Read actions use the delta store until the invisible compressed segment is completed. Then the new segment is made visible, and the source delta store is removed.<br /><br />`OPEN` - A read/write row group that's accepting new rows. An open row group is still in rowstore format and isn't compressed to columnstore format.<br /><br />`CLOSED` - A row group that is filled, but not yet compressed by the tuple mover process.<br /><br />`COMPRESSED` - A row group that is filled and compressed. |
40+
| `total_rows` | **bigint** | Total rows physically stored in the row group. Deleted rows might still be stored. The maximum number of rows in a row group is 1,048,576. |
41+
| `deleted_rows` | **bigint** | Total rows in the row group that are marked deleted but remain stored. This value is always `0` for delta row groups.<br /><br />For nonclustered columnstore indexes, this value doesn't include deleted rows stored in the delete buffer. For more information, and to find the number of deleted rows in the delete buffer, see [sys.internal_partitions](sys-internal-partitions-transact-sql.md). |
42+
| `size_in_bytes` | **bigint** | Size in bytes of all the data in this row group (not including metadata or shared dictionaries), for both delta store and columnstore rowgroups. |
43+
44+
## Remarks
45+
46+
Returns one row for each columnstore row group for each partition of each table that has a clustered or nonclustered columnstore index.
47+
48+
Use `sys.column_store_row_groups` to find out how many rows are in the row group and the size of the row group.
49+
50+
When the number of deleted rows in a row group grows to a large percentage of the total rows, the table becomes less efficient. Rebuild the columnstore index to reduce the size of the table, reducing the disk I/O required to read the table. To rebuild the columnstore index, use the `REBUILD` clause of the `ALTER INDEX` statement.
51+
52+
The updatable columnstore first inserts new data into an open rowgroup, which is in rowstore format, and is also sometimes referred to as a delta table. Once an open rowgroup is full, its state changes to `CLOSED`. A closed rowgroup is compressed into columnstore format by the tuple mover and the state changes to `COMPRESSED`. The tuple mover is a background process that periodically wakes up and checks whether there are any closed rowgroups that are ready to compress into a columnstore rowgroup. The tuple mover also deallocates any rowgroups in which every row is deleted. Deallocated rowgroups are marked as `TOMBSTONE`. To run tuple mover immediately, use the `REORGANIZE` clause of the `ALTER INDEX` statement.
53+
54+
When a columnstore row group fills, it's compressed, and stops accepting new rows. When you delete rows from a compressed group, they remain but are marked as deleted. Updates to a compressed group are implemented as a delete from the compressed group, and an insert to an open group.
55+
56+
## Permissions
57+
58+
Returns information for a table if the user has `VIEW DEFINITION` permission on the table.
59+
60+
[!INCLUDE [ssCatViewPerm](../../includes/sscatviewperm-md.md)] For more information, see [Metadata visibility configuration](../security/metadata-visibility-configuration.md).
61+
62+
## Examples
63+
64+
The following example joins the `sys.column_store_row_groups` view and other system views to return information about clustered columnstore indexes. The `percent_full` column is an estimate of the efficiency of the row group.
65+
66+
```sql
67+
SELECT i.object_id,
68+
OBJECT_SCHEMA_NAME(i.object_id) AS schema_name,
69+
OBJECT_NAME(i.object_id) AS table_name,
70+
i.name AS index_name,
71+
i.type_desc AS index_type_desc,
72+
rg.partition_number,
73+
rg.row_group_id,
74+
rg.state_description,
75+
rg.total_rows,
76+
rg.deleted_rows,
77+
rg.size_in_bytes,
78+
100 * (rg.total_rows - ISNULL(rg.deleted_rows, 0)) / total_rows AS percent_full
79+
FROM sys.indexes AS i
80+
INNER JOIN sys.column_store_row_groups AS rg
81+
ON i.object_id = rg.object_id
82+
AND i.index_id = rg.index_id
83+
WHERE INDEXPROPERTY(i.object_id, i.name, 'IsClustered') = 1
84+
ORDER BY schema_name, table_name, index_name, row_group_id;
85+
```
86+
87+
For more information, see [Check the fragmentation of a columnstore index](../indexes/reorganize-and-rebuild-indexes.md#check-the-fragmentation-of-a-columnstore-index).
88+
89+
## Related content
90+
91+
- [Columnstore indexes: overview](../indexes/columnstore-indexes-overview.md)
92+
- [sys.dm_db_column_store_row_group_physical_stats](../system-dynamic-management-views/sys-dm-db-column-store-row-group-physical-stats-transact-sql.md)
93+
- [sys.column_store_dictionaries [Transact-SQL]](sys-column-store-dictionaries-transact-sql.md)
94+
- [sys.column_store_segments [Transact-SQL]](sys-column-store-segments-transact-sql.md)
95+
- [Querying the SQL Server System Catalog FAQ](querying-the-sql-server-system-catalog-faq.yml)

0 commit comments

Comments
 (0)