Skip to content

Instantly share code, notes, and snippets.

View MarkPryceMaherMSFT's full-sized avatar

Mark Pryce-Maher MarkPryceMaherMSFT

View GitHub Profile
@MarkPryceMaherMSFT
MarkPryceMaherMSFT / under_presure.sql
Last active September 18, 2026 11:44
A quick script to see if the SQL pool is under presure
select dt_Date, pressure,pressure_no,
case
when pressure_no = 0 then 'No pressure, you can lower'
when pressure_no <=25 then 'Small amount of pressure - try lowering'
when pressure_no <=50 then 'Some amount of pressure - consider lowering'
when pressure_no <=75 then 'A lot of pressure'
else 'Mostly under pressure'
end rr
from (
select t.dt_Date, case t._under_pressure when 0 then 'No pressure'
@MarkPryceMaherMSFT
MarkPryceMaherMSFT / daily_10_min_cancelssql
Created September 14, 2026 12:31
Daily Trend of 10 min errors
DECLARE @days INT = 30;
DECLARE @timeout_s INT = 600;
DECLARE @tolerance_s INT = 30;
SELECT
CONVERT(DATE, submit_time) AS day_utc,
COUNT(*) AS client_timeout_cancels,
COUNT(DISTINCT query_hash) AS distinct_statements,
SUM(allocated_cpu_time_ms) AS wasted_cpu_ms,
CAST(SUM(allocated_cpu_time_ms) / 3600000.0 AS DECIMAL(18, 2)) AS wasted_cpu_hours
@MarkPryceMaherMSFT
MarkPryceMaherMSFT / queries_hitting_the_10min_timeout.sql
Created September 14, 2026 12:23
Queries hitting the 10 min timeout
DECLARE @days INT = 30;
DECLARE @timeout_s INT = 600;
DECLARE @tolerance_s INT = 30;
WITH timeouts AS (
SELECT
query_hash,
ISNULL(program_name, '(none supplied)') AS program_name,
login_name,
statement_type,
WITH cancels AS (
SELECT
ISNULL(program_name, '(none supplied)') AS program_name,
error_code,
allocated_cpu_time_ms,
DATEDIFF(SECOND, submit_time, end_time) AS client_elapsed_s
FROM queryinsights.exec_requests_history
WHERE submit_time >= DATEADD(DAY, -30, GETUTCDATE())
AND UPPER(status) LIKE 'CANCEL%' -- 'Canceled', one L. See header.
--AND end_time IS NOT NULL
@MarkPryceMaherMSFT
MarkPryceMaherMSFT / Errors_ by_application.sql
Created September 14, 2026 11:54
Errors by application
SELECT
ISNULL(program_name, '(none supplied)') AS program_name,
status,
error_code,
CASE
WHEN error_code = 3617 THEN 'client sent abort signal (cancel or client-side timeout)'
WHEN error_code = 0 THEN 'no error recorded'
ELSE error_code
END AS error_meaning,
COUNT(*) AS queries,
CREATE OR ALTER PROCEDURE dbo.usp_DropSchema
@SchemaName sysname,
@DropSchema bit = 1,
@WhatIf bit = 0,
@Print bit = 1,
@MaxPasses int = 10
AS
BEGIN
@MarkPryceMaherMSFT
MarkPryceMaherMSFT / delta-v2-checkpoints-demo.ipynb
Last active September 2, 2026 15:05
Notebook that creates a table with v2 checkpoints enabled
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import json
import notebookutils
import sempy.fabric as fabric
workspace_id=spark.conf.get("trident.workspace.id")
lakehouse_id=spark.conf.get("trident.lakehouse.id")
#Instantiate the client
client = fabric.FabricRestClient()
sqlendpoint = fabric.FabricRestClient().get(f"/v1/workspaces/{workspace_id}/lakehouses/{lakehouse_id}").json()['properties']['sqlEndpointProperties']['id']
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"