Skip to content

Commit 8a93323

Browse files
authored
Merge pull request #16459 from MightyPen/july29g
Alternative fix for public PR 5193. Add WHERE GT 0.
2 parents a97c7a3 + 5484c8d commit 8a93323

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

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

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "sys.pdw_nodes_column_store_row_groups (Transact-SQL)"
33
ms.custom: seo-dt-2019
4-
ms.date: "03/03/2017"
4+
ms.date: 08/05/2020
55
ms.prod: sql
66
ms.technology: data-warehouse
77
ms.reviewer: ""
@@ -50,7 +50,7 @@ monikerRange: ">= aps-pdw-2016 || = azure-sqldw-latest || = sqlallproducts-allve
5050
## Examples: [!INCLUDE[ssSDW](../../includes/sssdw-md.md)] and [!INCLUDE[ssPDW](../../includes/sspdw-md.md)]
5151
The following example joins the **sys.pdw_nodes_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.
5252

53-
```
53+
```sql
5454
SELECT IndexMap.object_id,
5555
object_name(IndexMap.object_id) AS LogicalTableName,
5656
i.name AS LogicalIndexName, IndexMap.index_id, NI.type_desc,
@@ -69,14 +69,15 @@ JOIN sys.pdw_nodes_indexes AS NI
6969
JOIN sys.pdw_nodes_column_store_row_groups AS CSRowGroups
7070
ON CSRowGroups.object_id = NI.object_id
7171
AND CSRowGroups.pdw_node_id = NI.pdw_node_id
72-
AND CSRowGroups.index_id = NI.index_id
72+
AND CSRowGroups.index_id = NI.index_id
73+
WHERE total_rows > 0
7374
--WHERE t.name = '<table_name>'
7475
ORDER BY object_name(i.object_id), i.name, IndexMap.physical_name, pdw_node_id;
7576
```
7677

7778
The following [!INCLUDE[ssSDW_md](../../includes/sssdw-md.md)] example counts the rows per partition for clustered column stores as well as how many rows are in Open, Closed, or Compressed Row groups:
7879

79-
```
80+
```sql
8081
SELECT
8182
s.name AS [Schema Name]
8283
,t.name AS [Table Name]
@@ -86,14 +87,16 @@ SELECT
8687
,SUM(CASE WHEN rg.State = 2 THEN rg.Total_Rows ELSE 0 END) AS [Rows in Closed Row Groups]
8788
,SUM(CASE WHEN rg.State = 3 THEN rg.Total_Rows ELSE 0 END) AS [Rows in COMPRESSED Row Groups]
8889
FROM sys.pdw_nodes_column_store_row_groups rg
89-
JOIN sys.pdw_nodes_tables pt
90-
ON rg.object_id = pt.object_id AND rg.pdw_node_id = pt.pdw_node_id AND pt.distribution_id = rg.distribution_id
91-
JOIN sys.pdw_table_mappings tm
92-
ON pt.name = tm.physical_name
93-
INNER JOIN sys.tables t
94-
ON tm.object_id = t.object_id
95-
INNER JOIN sys.schemas s
96-
ON t.schema_id = s.schema_id
90+
JOIN sys.pdw_nodes_tables pt
91+
ON rg.object_id = pt.object_id
92+
AND rg.pdw_node_id = pt.pdw_node_id
93+
AND pt.distribution_id = rg.distribution_id
94+
JOIN sys.pdw_table_mappings tm
95+
ON pt.name = tm.physical_name
96+
INNER JOIN sys.tables t
97+
ON tm.object_id = t.object_id
98+
INNER JOIN sys.schemas s
99+
ON t.schema_id = s.schema_id
97100
GROUP BY s.name, t.name, rg.partition_number
98101
ORDER BY 1, 2
99102
```

0 commit comments

Comments
 (0)