-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create Index usage stats for each table in Azure Synapse.sql
- Loading branch information
1 parent
8413755
commit 9665a4f
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
Synapse/Index usage stats for each table in Azure Synapse.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
|
||
/********************************************************************************************************* | ||
Author: Eitan Blumin @Madeira | ||
Created Date: 2025-02-04 | ||
Description: This script retrieve index usage stats for each table in Azure Synapse Analytics | ||
**********************************************************************************************************/ | ||
|
||
SELECT | ||
SchemaName = sch.[name] , | ||
TableName = t.[name] , | ||
ius.* | ||
FROM | ||
sys.schemas AS sch | ||
INNER JOIN | ||
sys.tables AS t | ||
ON | ||
sch.[schema_id] = t.[schema_id] | ||
INNER JOIN | ||
sys.indexes AS ix | ||
ON | ||
t.[object_id] = ix.[object_id] | ||
AND | ||
ix.[index_id] <= 1 | ||
INNER JOIN | ||
sys.pdw_permanent_table_mappings AS tmap | ||
ON | ||
t.[object_id] = tmap.[object_id] | ||
INNER JOIN | ||
sys.pdw_nodes_tables AS ntab | ||
ON | ||
tmap.[physical_name] = ntab.[name] | ||
LEFT JOIN | ||
sys.dm_pdw_nodes_db_index_usage_stats AS ius | ||
ON | ||
ntab.[object_id] = ius.[object_id] | ||
AND ntab.[pdw_node_id] = ius.[pdw_node_id] | ||
--AND ntab.[distribution_id] = ius.[distribution_id] | ||
--GROUP BY | ||
-- sch.[name] , | ||
-- t.[name]; | ||
GO |