title | description | author | ms.author | ms.reviewer | ms.date | ms.service | ms.subservice | ms.topic | dev_langs | monikerRange | |
---|---|---|---|---|---|---|---|---|---|---|---|
DBCC PDW_SHOWMATERIALIZEDVIEWOVERHEAD (Transact-SQL) |
DBCC PDW_SHOWMATERIALIZEDVIEWOVERHEAD Displays the number of incremental changes in the base tables that are held for materialized views for Azure Synapse Analytics or Analytics Platform System (PDW). |
XiaoyuMSFT |
xiaoyul |
randolphwest |
12/05/2022 |
sql |
data-warehouse |
reference |
|
= azure-sqldw-latest |
[!INCLUDE asa]
Displays the number of incremental changes in the base tables that are held for materialized views in [!INCLUDEssazuresynapse-md]. The overhead ratio is calculated as TOTAL_ROWS / MAX (1, BASE_VIEW_ROWS).
:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions
DBCC PDW_SHOWMATERIALIZEDVIEWOVERHEAD ( "[ schema_name . ] materialized_view_name" )
[;]
Note
[!INCLUDEsynapse-analytics-od-unsupported-syntax]
The name of the schema to which the view belongs.
The name of the materialized view.
To keep materialized views refreshed with data changes in base tables, data warehouse engine adds tracking rows to each affected view to reflect the changes. Selecting from a materialized view includes scanning the view's clustered columnstore index and applying any incremental changes. The tracking rows (TOTAL_ROWS - BASE_VIEW_ROWS) don't get eliminated until users REBUILD the materialized view.
The overhead_ratio is calculated as TOTAL_ROWS / MAX(1, BASE_VIEW_ROWS). If it's high, SELECT performance will degrade. Users can rebuild the materialized view to reduce its overhead ratio.
Requires VIEW DATABASE STATE permission.
DBCC PDW_SHOWMATERIALIZEDVIEWOVERHEAD ("dbo.MyIndexedView");
Sample output:
OBJECT_ID | BASE_VIEW_ROWS | TOTAL_ROWS | OVERHEAD_RATIO |
---|---|---|---|
1234 | 1 | 3 | 3.0 |
Create a table:
CREATE TABLE t1 (c1 INT NOT NULL, c2 INT NOT NULL, c3 INT NOT NULL);
Insert five rows into t1
:
INSERT INTO t1 VALUES (1, 1, 1);
INSERT INTO t1 VALUES (2, 2, 2);
INSERT INTO t1 VALUES (3, 3, 3);
INSERT INTO t1 VALUES (4, 4, 4);
INSERT INTO t1 VALUES (5, 5, 5);
Create materialized views MV1:
CREATE MATERIALIZED VIEW MV1
WITH (DISTRIBUTION = HASH(c1))
AS
SELECT c1, COUNT(*) total_number
FROM dbo.t1 WHERE c1 < 3
GROUP BY c1;
Selecting from the materialized view returns two rows.
c1 | total_number |
---|---|
1 | 1 |
2 | 1 |
Check the materialized view overhead before any data changes in the base table.
DBCC PDW_SHOWMATERIALIZEDVIEWOVERHEAD ("dbo.mv1")
Sample output:
OBJECT_ID | BASE_VIEW_ROWS | TOTAL_ROWS | OVERHEAD_RATIO |
---|---|---|---|
587149137 | 2 | 2 | 1.00000000000000000 |
Update the base table. This query updates the same column in the same row 100 times to the same value. The materialized view content doesn't change.
DECLARE @p INT;
SELECT @p = 1;
WHILE (@p < 101)
BEGIN
UPDATE t1 SET c1 = 1 WHERE c1 = 1;
SELECT @p = @p + 1;
END;
Selecting from the materialized view returns the same result as before.
c1 | total_number |
---|---|
1 | 1 |
2 | 1 |
Below is the output from DBCC PDW_SHOWMATERIALIZEDVIEWOVERHEAD ("dbo.mv1")
. 100 rows are added to the materialized view (total_row - base_view_rows) and its overhead_ratio is increased.
OBJECT_ID | BASE_VIEW_ROWS | TOTAL_ROWS | OVERHEAD_RATIO |
---|---|---|---|
587149137 | 2 | 102 | 51.00000000000000000 |
After rebuilding the materialized view, all tracking rows for incremental data changes are eliminated and the view overhead ratio is reduced.
ALTER MATERIALIZED VIEW dbo.MV1 REBUILD
GO
DBCC PDW_SHOWMATERIALIZEDVIEWOVERHEAD ("dbo.mv1")
Output
| OBJECT_ID | BASE_VIEW_ROWS | TOTAL_ROWS | OVERHEAD_RATIO |
| --- | --- | --- | --- |
| 587149137 | 2 | 2 | 1.00000000000000000 |
- Performance tuning with Materialized View
- CREATE MATERIALIZED VIEW AS SELECT (Transact-SQL)
- ALTER MATERIALIZED VIEW (Transact-SQL)
- EXPLAIN (Transact-SQL)
- sys.pdw_materialized_view_column_distribution_properties (Transact-SQL)
- sys.pdw_materialized_view_distribution_properties (Transact-SQL)
- sys.pdw_materialized_view_mappings (Transact-SQL)
- Azure Synapse Analytics and Parallel Data Warehouse Catalog Views
- System views supported in Azure Synapse Analytics
- T-SQL statements supported in Azure Synapse Analytics