1
我需要幫助重新編寫以下查詢以使其更快。最終,我想要的是每個服務器的一行(標題)和相應的指標。如果我刪除最大和Avgs,我得到每臺服務器1600行,並在3秒內運行。如果我添加它們,計算單個服務器的數據大約需要3分鐘。服務器總數超過11K。需要幫助才能使得這個速度更快
SELECT
Nodes.Caption, COUNT(DISTINCT CPUMultiLoad_Detail.CPUIndex) AS CPUCount,
Max(CPULoad.MaxLoad) as MaxCPU, Avg(CPULoad.AvgLoad) as AvgCPU,
Round((CPULoad.TotalMemory/1073741824),0) as MemCount,
Round(Max(CPULoad.MaxMemoryUsed/CPULoad.TotalMemory * 100),2) as MaxMem,
Round(Avg(CPULoad.AvgPercentMemoryUsed),2) as AvgMem
FROM
Nodes
INNER JOIN
CPUMultiLoad_Detail ON Nodes.NodeID = CPUMultiLoad_Detail.NodeID
INNER JOIN
CPULoad ON Nodes.NodeID = CPULoad.NodeID
WHERE CPULoad.Datetime >= DATEADD(month,datediff(month,0,getdate())-1,0)
and CPULoad.Datetime < DATEADD(day,datediff(day,0,getdate()),1)
GROUP BY Nodes.Caption, CPULoad.TotalMemory
顯示錶的佈局和索引和PK,你是否被允許添加/修改現有的索引 – objectNotFound
你能不能也發佈實際執行計劃? –
你打算在cpuLoad.totalMemory周圍有一個聚合函數(SUM?)嗎? – Beth