我在下面有一個MDX查詢。此查詢有效,問題是速度慢,即使數據集不是很大,也需要15秒才能返回結果。我相信查詢應該在2秒內執行(它也用於登錄頁面,等待時間很麻煩)。 [度量]。[星級]由於所有IF THEN ELSE邏輯而導致速度減慢。它的所有操作都基於[平均分],它根據查找表中的範圍從查找表中找到[星級]。 例如如果[平均分數] < 86,[星級] = 1 如果[平均分]> = 86和< = 90,[星級] = 2SSAS根據另一個計算的度量計算度量值
的[平均分]是一個簡單的總和/數計算。 它可以根據用作參數的日期範圍進行更改。 您可以推薦在下面的現有查詢中進行優化,還是推薦一種替代方法來計算[星級]?
MDX查詢低於:
WITH
MEMBER [Measures].[MeanScore] AS ([Measures].[Standard Point Assignment - Sum]/[Measures].[Episode Of Care HCAHPS Count])
MEMBER [Measures].[StarRating] AS
CASE
WHEN [HCAHPS Star Rating].[HCAHPS Star Rating ID].CurrentMember IS [HCAHPS Star Rating].[HCAHPS Star Rating ID].[All]
THEN
CASE
WHEN [Measures].[HSR-HCHCAHPS Domain ID] = TAIL([HCAHPS Star Rating].[HCAHPS Star Rating ID].[HCAHPS Star Rating ID]).Item(0).Item(0).Properties('HCHCAHPS Domain ID')
THEN
(
[Measures].[Rating],
Tail([HCAHPS Star Rating].[HCAHPS Star Rating ID].[HCAHPS Star Rating ID]).Item(0).Item(0)
)
ELSE
(
[Measures].[StarRating],
Tail([HCAHPS Star Rating].[HCAHPS Star Rating ID].[HCAHPS Star Rating ID]).Item(0).Item(0).PrevMember
)
END
ELSE
CASE
WHEN [Measures].[MeanScore] > [HCAHPS Star Rating].[HCAHPS Star Rating ID].CurrentMember.Properties('Start', typed)
AND [Measures].[HC-HCAHPS Domain ID] = [HCAHPS Star Rating].[HCAHPS Star Rating ID].CurrentMember.Properties('HCHCAHPS Domain ID', typed)
THEN
(
[Measures].[Rating],
[HCAHPS Star Rating].[HCAHPS Star Rating ID].CurrentMember
)
ELSE
(
[Measures].[StarRating],
[HCAHPS Star Rating].[HCAHPS Star Rating ID].CurrentMember.PrevMember
)
END
END
SELECT
{
[Measures].[Episode Of Care HCAHPS Count]
,[Measures].[Is Top Box]
,[Measures].[CompositeScore]
,[Measures].[PromoterCount]
,[Measures].[PromoterPercent]
,[Measures].[PassiveCount]
,[Measures].[PassivePercent]
,[Measures].[DetractorCount]
,[Measures].[DetractorPercent]
,[Measures].[StarRating]
,[Measures].[MeanScore]
} ON COLUMNS,
NONEMPTYCROSSJOIN
(
{NONEMPTY([HCAHPS Domain].[HCAHPS Survey Methodology ID].[HCAHPS Survey Methodology ID])}
,DESCENDANTS(StrToSet('[Org Hierarchy].[Parent Key].&[118418]'))
,{[HCHCAHPS Domain].[HC Domain Group].[HC Domain Group]}
,{[HCHCAHPS Domain].[HCAHPS Domain Name].[HCAHPS Domain Name]}
,{[HCAHPS Question Answer].[Question Number].AllMembers}
) ON ROWS
FROM [CAHPS]
WHERE
(
StrToMember("[Date].[Date].&[" + FORMAT(NOW()-365,"yyyy-MM-ddT00:00:00") + "]",CONSTRAINED):StrToMember("[Date].[Date].&[" + FORMAT(NOW(),"yyyy-MM-ddT00:00:00") + "]",CONSTRAINED)
)
沒有愛的3.2.1節這個...任何人? – SQLSeeker