From e87c930a9ef401edfd168333c0b6dc5ccfd98d67 Mon Sep 17 00:00:00 2001 From: meyergm Date: Thu, 31 Mar 2016 20:00:14 -0700 Subject: [PATCH] Added Azure Data Warehouse files. --- .../Scripts/AzureSQLDWHOLCommands.sql | 48 +++++++++++++++++++ .../Scripts/Step 15 High CPU Query.sql | 19 ++++++++ 2 files changed, 67 insertions(+) create mode 100644 Supporting/DataWarehouse/Scripts/AzureSQLDWHOLCommands.sql create mode 100644 Supporting/DataWarehouse/Scripts/Step 15 High CPU Query.sql diff --git a/Supporting/DataWarehouse/Scripts/AzureSQLDWHOLCommands.sql b/Supporting/DataWarehouse/Scripts/AzureSQLDWHOLCommands.sql new file mode 100644 index 0000000..4bccc1a --- /dev/null +++ b/Supporting/DataWarehouse/Scripts/AzureSQLDWHOLCommands.sql @@ -0,0 +1,48 @@ +/*Step 23 Retrieve Connection information*/ + +SELECT * FROM sys.dm_pdw_nodes_exec_connections; +SELECT * FROM sys.dm_pdw_nodes_exec_sessions; + +/*Step 24 Retrieve Current Connection information*/ + +SELECT * +FROM sys.dm_pdw_nodes_exec_connections AS c + JOIN sys.dm_pdw_nodes_exec_sessions AS s + ON c.session_id = s.session_id +WHERE c.session_id = @@SPID; + +/*Step 25 View Running Queries*/ + +SELECT * FROM sys.dm_pdw_exec_requests WHERE status = 'Running'; + +SELECT * FROM sys.dm_pdw_exec_requests ORDER BY total_elapsed_time DESC; + +/*Step 26 View queries waiting for resources*/ + +SELECT waits.session_id, + waits.request_id, + requests.command, + requests.status, + requests.start_time, + waits.type, + waits.object_type, + waits.object_name, + waits.state +FROM sys.dm_pdw_waits waits + JOIN sys.dm_pdw_exec_requests requests + ON waits.request_id=requests.request_id +ORDER BY waits.object_name, waits.object_type, waits.state; + +/*Step 27 View long running Query*/ + +SELECT * FROM sys.dm_pdw_request_steps +WHERE request_id = 'QID' +ORDER BY step_index; + +/*Step 28 View total elapsed time for long-running query*/ + +SELECT * FROM sys.dm_pdw_sql_requests +WHERE request_id = 'QID' AND step_index = ; + + + diff --git a/Supporting/DataWarehouse/Scripts/Step 15 High CPU Query.sql b/Supporting/DataWarehouse/Scripts/Step 15 High CPU Query.sql new file mode 100644 index 0000000..87018b8 --- /dev/null +++ b/Supporting/DataWarehouse/Scripts/Step 15 High CPU Query.sql @@ -0,0 +1,19 @@ +SELECT +SalesOrderNumber as SalesOrderNumber, +CustomerKey as CustomerKey, +COUNT(OnlineSalesKey) as OnlineSalesKey, +AVG(SalesQuantity) as SalesQuantity, +AVG(SalesAmount) as SalesAmount, +AVG(DiscountAmount) As DiscountAmount, +AVG(DiscountQuantity) As DiscountQuantity, +AVG(UnitCost) as UnitCost, +AVG(UnitPrice) as UnitPrice, +AVG((SalesAmount-DiscountAmount)) As SalesAmountDifference, +AVG((SalesQuantity - DiscountQuantity)) as SalesQuantityDifference +FROM +FactSales +GROUP BY +SalesOrderNumber, +CustomerKey +HAVING +AVG(SalesQuantity) > 2 \ No newline at end of file