我有一個保存到SQL Server表中的SQL事件探查器跟蹤。字符串列搜索/替換GUID
我想執行跟蹤查詢的CPU /讀取/持續時間的和/平均/計數分析。但大多數的剖析數據記錄存儲過程調用與uniqueidentifer
參數(S):
EXECUTE GetTransactionCounts @BankGUID = '{231281D7-F6C2-4EAE-98AE-E9196D8016F0}', @SessionGUID='{7F34361F-CEEA-4CEA-8CBD-2704FFE92DEF}'
SELECT SUM(Total) AS Total FROM fn_BalancingAdditionsUS('{C08961DB-0B6A-4E67-A82B-5BBBA0A84A74}')
EXEC CreateCloser '{7F34361F-CEEA-4CEA-8CBD-2704FFE92DEF}', NULL , '{08E74DBB-3BC4-49A7-AA10-95AA6BD24784}'
EXECUTE GetMachineImpressmentForSession @SessionGUID = '{446881BA-1439-4AD8-B33B-C784120EFBA2}'
SELECT SUM(Total) AS Total FROM fn_BalancingAdditionsCanadian('{446881BA-1439-4AD8-B33B-C784120EFBA2}')
SELECT SUM(Total) AS Total FROM fn_BalancingSubtractionsUS('{446881BA-1439-4AD8-B33B-C784120EFBA2}')
所以,當我試圖聚集探查器跟蹤數據發現表現最差的查詢:
SELECT
Description,
COUNT(*) AS EventCount,
AVG(CPU) AS CPU, SUM(CPU) AS CpuTotal,
AVG(Reads) AS Reads, SUM(Reads) AS ReadsTotal,
AVG(Duration) AS Duration, SUM(Duration) AS DurationTotal
FROM SlowQueriesTrace
GROUP BY Description
然後不會發生聚合,因爲每個GUID都是唯一的。我需要的是某種方式與通用%g
標誌更換唯一標識符參數:
EXECUTE GetTransactionCounts @BankGUID = %g, @SessionGUID=%g
SELECT SUM(Total) AS Total FROM fn_BalancingAdditionsUS(%g)
EXEC CreateCloser %g, NULL , %g
EXECUTE GetMachineImpressmentForSession @SessionGUID = %g
SELECT SUM(Total) AS Total FROM fn_BalancingAdditionsCanadian(%g)
SELECT SUM(Total) AS Total FROM fn_BalancingSubtractionsUS(%g)
然後我就能匯聚工作。
除了將表格導出到Excel和手動編輯所有10,270個事件之外,任何想法都可以用任何方式執行GUID搜索&替換SQL Server內部的模式匹配?
其他黑客,我試圖:
修剪description
到前40個字符(即CAST(description AS varchar(40))
):
EXECUTE GetTransactionCounts @BankGUID =
SELECT SUM(Total) AS Total FROM fn_Balan
EXEC CreateCloser '{7F34361F-CEEA-4CEA-8
EXECUTE GetMachineImpressmentForSession
SELECT SUM(Total) AS Total FROM fn_Balan
SELECT SUM(Total) AS Total FROM fn_Balan
除了合併不應該合併的項目和其他項目應該合併的不是。
使用的SoundEx:
E223
S423
E220
E223
S423
除了可以看到完全不同被賦予相同的同音線。此外,我無法確定什麼查詢S338
對應。
我最終使用的黑客創建了一個新的Category
列,初始爲null。然後,我用精心挑選的LIKE
條款花了兩個小時挑出一個特定的查詢,然後用查詢「標記」它們。例如: -
UPDATE QueryTrace
SET Category = 'EXECUTE GetTransactionCounts @BankGUID ='
WHERE Description LIKE 'EXECUTE GetTransactionCounts @BankGUID =%'
和
UPDATE QueryTrace
SET Category = 'SELECT SUM(Total) AS Total FROM fn_BalancingAdditionsCanadian'
WHERE Description LIKE '%FROM fn_BalancingAdditionsCanadian%'
這並不意味着我不需要用這個問題的解決方案。
+1 ClearTrace完全是*去這裏的路。它很容易使用,專門爲解決您正在處理的問題而構建。 –
希望不是唯一的出路。 –
我多次使用過ClearTrace,並沒有遇到那個錯誤 –