This file contains hidden or 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
| import struct | |
| import pyodbc | |
| import pandas as pd | |
| from azure.identity import ClientSecretCredential | |
| import jwt | |
| tenant_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" | |
| client_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" | |
| client_secret = "Nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" |
This file contains hidden or 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
| -- https://learn.microsoft.com/en-us/fabric/data-warehouse/monitor-using-dmv | |
| -- connections/sessions/queries | |
| select * from sys.dm_exec_connections; | |
| select * from sys.dm_exec_sessions; | |
| select * from sys.dm_exec_requests; | |
| select * from sys.dm_exec_query_stats; | |
| -- query text | |
| select st.text | |
| FROM sys.dm_exec_requests r |
This file contains hidden or 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
| 10TB dataset | ||||
|---|---|---|---|---|
| Pool Size: 100% | ||||
| Query | Not Read Optimized | Read Optimized | Improvement | |
| Q1 | 5.408 | 0.975 | 5.5x | |
| Q2 | 35.304 | 5.333 | 6.6x | |
| Q3 | 84.184 | 8.026 | 10.5x | |
| Q4 | 49.687 | 10.474 | 4.7x | |
| Q5 | 104.358 | 18.64 | 5.6x | |
| Q6 | 16.753 | 0.398 | 42.1x | |
| Q7 | 75.211 | 4.46 | 16.9x |
This file contains hidden or 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
| Not Read-Optimized | Read-Optimized | Speedup | ||
|---|---|---|---|---|
| Q1 | 5.408s | 0.975s | 5.5x | |
| Q6 | 16.753s | 0.398s | 42x | |
| Q17 | 161.288s | 26.192s | 6.2x | |
| Q18 | 99.039s | 9.500s | 10.4x | |
| Q21 | 147.082s | 21.298s | 6.9x | |
| Overall | 4894.60s | 634.39s | ~7.7x |
This file contains hidden or 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
| CREATE FUNCTION dbo.ConvertUtcToFixedOffset | |
| ( | |
| @UtcTime DATETIME, | |
| @TimeZoneName VARCHAR(100) | |
| ) | |
| RETURNS DATETIME | |
| AS | |
| BEGIN | |
| DECLARE @OffsetMinutes INT; |
This file contains hidden or 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
| --DROP TABLE dbo.TimeZoneOffsets | |
| CREATE TABLE dbo.TimeZoneOffsets ( | |
| TimeZoneName VARCHAR(100) , | |
| OffsetMinutes INT | |
| ); | |
| INSERT INTO dbo.TimeZoneOffsets (TimeZoneName, OffsetMinutes) | |
| VALUES | |
| -- UTC |
This file contains hidden or 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
| DECLARE @sql NVARCHAR(MAX) = N''; | |
| SELECT @sql += | |
| 'BEGIN TRY '+ CHAR(13) + ' UPDATE STATISTICS [' + s.name + '].[' + t.name + '] [' + st.name + '] WITH FULLSCAN;' + CHAR(13) + 'END TRY' + CHAR(13)+ ' BEGIN CATCH' + CHAR(13) + ' PRINT ''Failed to update statistics on [' + s.name + '].[' + t.name + '] [' + st.name + ']'';' + CHAR(13) + 'END CATCH;' + CHAR(13) | |
| FROM sys.stats st | |
| JOIN sys.tables t ON st.object_id = t.object_id | |
| JOIN sys.schemas s ON t.schema_id = s.schema_id | |
| where st.name not in ('ClusteredIndex') and st.name not like 'ACE%' | |
| print @sql | |
| EXEC sp_executesql @sql; |
This file contains hidden or 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
| SELECT [distributed_statement_id], | |
| [database_name], | |
| [submit_time], | |
| [start_time], | |
| [end_time], | |
| [is_distributed], | |
| [statement_type], | |
| [total_elapsed_time_ms], | |
| [login_name], | |
| [row_count], |
This file contains hidden or 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
| SELECT | |
| s.name AS SchemaName, | |
| t.name AS TableName, | |
| c.name AS ColumnName, | |
| ty.name AS DataType, | |
| c.max_length, | |
| c.precision, | |
| c.scale, | |
| c.is_nullable | |
| FROM sys.tables t |
This file contains hidden or 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
| declare @list varchar(max) | |
| declare @sql nvarchar(max) | |
| drop table if exists sys_tables | |
| create table sys_tables (object_id bigint, tablename varchar(50)) | |
| SELECT @list = STRING_AGG('(' + CAST([object_id] AS VARCHAR(20)) + ', ''' + CAST([name] AS VARCHAR(128)) + ''')', ',') FROM sys.tables | |
| SET @sql = 'INSERT INTO sys_tables (object_id, tablename) VALUES ' + @list | |
| --print @sql | |
| exec sp_executesql @sql | |
NewerOlder