过滤后的计数和总和的 MDX 性能问题 Members/Measures
MDX Performance Issues on Count & Sum of Filtered Members/Measures
我有以下 MDX 查询,我需要 运行 多维数据集(我无权更改)。
此特定查询到 运行 大约需要 1.5 分钟,这实在是太长了。我一直在寻找一种加快速度的方法,但我运气不佳。
谁能找到改进此查询的方法?过去几天我一直在撕扯我的头发,所以任何帮助将不胜感激!
`WITH
MEMBER [Measures].[1-99_Count] AS
COUNT(FILTER ([Scam].[Scam Ref].AllMembers,
([Measures].[Amount Lost]>=1 AND [Measures].[Amount Lost]<=99)))
MEMBER [Measures].[1-99_Amount] AS
SUM(FILTER ([Scam].[Scam Ref].AllMembers,
([Measures].[Amount Lost]>=1 AND [Measures].[Amount Lost]<=99)),
Iif(IsEmpty([Measures].[Amount Lost]),0,[Measures].[Amount Lost]))
SELECT {[Measures].[1-99_Count],
[Measures].[1-99_Amount]} ON COLUMNS,
[First Resolved On Date].[Month].[Month] ON ROWS
FROM [Infocentre]
WHERE ([First Resolved On Date].[Date].[Date].&[20140101]:[First Resolved On Date].[Date].[Date].&[20150623],
[Scam].[Scam Category Level1].&[{d9d6bc38-e73e-e411-9a82-0a713f2121f7}])`
最后,逻辑占了上风,我能够让立方体所有者为立方体添加一个新维度,这意味着我不再需要尝试让这只狗的早餐正常工作。
(纯属娱乐!)
您的第一项措施绝对可以通过以下措施得到改进。
Count(Filter
是一种您在大多数情况下都可以摆脱的模式。
Mosha 在博客上介绍了这种模式,可以改进,在这里:
http://sqlblog.com/blogs/mosha/archive/2007/11/22/optimizing-count-filter-expressions-in-mdx.aspx
我也尝试改进第二个计算。如果这个条件为真 [Measures].[Amount Lost] >= 1 AND [Measures].[Amount Lost] <= 99
那么这一定意味着这是假的 IsEmpty([Measures].[Amount Lost]) 所以也许这两个条件都可以被 1 个条件覆盖。还用 null
替换了你的 0
- SSAS 用 null
:
更快乐(更快)
WITH
MEMBER [Measures].[1-99_Count] AS
Sum
(
[Scam].[Scam Ref].ALLMEMBERS
,IIF
(
[Measures].[Amount Lost] >= 1 AND [Measures].[Amount Lost] <= 99
,1
,null
)
)
MEMBER [Measures].[1-99_Amount] AS
Sum
(
[Scam].[Scam Ref].ALLMEMBERS
,IIF
(
[Measures].[Amount Lost] >= 1 AND [Measures].[Amount Lost] <= 99
,[Measures].[Amount Lost]
,null
)
)
SELECT
{
[Measures].[1-99_Count]
,[Measures].[1-99_Amount]
} ON COLUMNS
,[First Resolved On Date].[Month].[Month] ON ROWS
FROM [Infocentre]
WHERE
(
[First Resolved On Date].[Date].[Date].&[20140101]
:
[First Resolved On Date].[Date].[Date].&[20150623]
,[Scam].[Scam Category Level1].&[{d9d6bc38-e73e-e411-9a82-0a713f2121f7}]
);
我有以下 MDX 查询,我需要 运行 多维数据集(我无权更改)。
此特定查询到 运行 大约需要 1.5 分钟,这实在是太长了。我一直在寻找一种加快速度的方法,但我运气不佳。
谁能找到改进此查询的方法?过去几天我一直在撕扯我的头发,所以任何帮助将不胜感激!
`WITH
MEMBER [Measures].[1-99_Count] AS
COUNT(FILTER ([Scam].[Scam Ref].AllMembers,
([Measures].[Amount Lost]>=1 AND [Measures].[Amount Lost]<=99)))
MEMBER [Measures].[1-99_Amount] AS
SUM(FILTER ([Scam].[Scam Ref].AllMembers,
([Measures].[Amount Lost]>=1 AND [Measures].[Amount Lost]<=99)),
Iif(IsEmpty([Measures].[Amount Lost]),0,[Measures].[Amount Lost]))
SELECT {[Measures].[1-99_Count],
[Measures].[1-99_Amount]} ON COLUMNS,
[First Resolved On Date].[Month].[Month] ON ROWS
FROM [Infocentre]
WHERE ([First Resolved On Date].[Date].[Date].&[20140101]:[First Resolved On Date].[Date].[Date].&[20150623],
[Scam].[Scam Category Level1].&[{d9d6bc38-e73e-e411-9a82-0a713f2121f7}])`
最后,逻辑占了上风,我能够让立方体所有者为立方体添加一个新维度,这意味着我不再需要尝试让这只狗的早餐正常工作。
(纯属娱乐!)
您的第一项措施绝对可以通过以下措施得到改进。
Count(Filter
是一种您在大多数情况下都可以摆脱的模式。
Mosha 在博客上介绍了这种模式,可以改进,在这里:
http://sqlblog.com/blogs/mosha/archive/2007/11/22/optimizing-count-filter-expressions-in-mdx.aspx
我也尝试改进第二个计算。如果这个条件为真 [Measures].[Amount Lost] >= 1 AND [Measures].[Amount Lost] <= 99
那么这一定意味着这是假的 IsEmpty([Measures].[Amount Lost]) 所以也许这两个条件都可以被 1 个条件覆盖。还用 null
替换了你的 0
- SSAS 用 null
:
WITH
MEMBER [Measures].[1-99_Count] AS
Sum
(
[Scam].[Scam Ref].ALLMEMBERS
,IIF
(
[Measures].[Amount Lost] >= 1 AND [Measures].[Amount Lost] <= 99
,1
,null
)
)
MEMBER [Measures].[1-99_Amount] AS
Sum
(
[Scam].[Scam Ref].ALLMEMBERS
,IIF
(
[Measures].[Amount Lost] >= 1 AND [Measures].[Amount Lost] <= 99
,[Measures].[Amount Lost]
,null
)
)
SELECT
{
[Measures].[1-99_Count]
,[Measures].[1-99_Amount]
} ON COLUMNS
,[First Resolved On Date].[Month].[Month] ON ROWS
FROM [Infocentre]
WHERE
(
[First Resolved On Date].[Date].[Date].&[20140101]
:
[First Resolved On Date].[Date].[Date].&[20150623]
,[Scam].[Scam Category Level1].&[{d9d6bc38-e73e-e411-9a82-0a713f2121f7}]
);