1

我正在尝试从以下多维表达式 (MDX) 查询中获取总金额超过 100k 的所有记录的详细列表:

with member [measures].[total] as 
[Measures].[m1] + [Measures].[m2] + [Measures].[m3]
select non empty
[measures].[total] on columns, 
non empty filter ([dim1].[h1].allmembers
* [dim1].[h2].allmembers
* [Loss Date].[Date].[Year].allmembers
* [Dim1].[h3].allmembers 
, [measures].[total]>100000 and [Measures].[Open File Count]>0) on rows
from [Monthly Summary]
where ([1 Date - Month End].[Month End Date].[Month].&[20120331])

虽然我通过创建存储过程获得了快速结果并且最终结果少于 1000 行,但我的 MDX 查询在 SSMS 中永远运行,并且在 SSRS 中返回内存异常。关于如何优化或增强它的任何想法?

4

3 回答 3

2

I would recommend a couple of changes.

First, do you really want the All member of each of your dimensions to be returned in the query? They will be included if they meet the condition in the filter. Also, I have found changing a where clause to a subselect to perform better in some cases. You need to test to see if it changes performance. Next, you can reduce the number of members that you're filtering by using a NonEmpty function first, by putting it inside the Filter function. Also, in some cases, using a polymorphic operator (*) performs worse than using a CrossJoin function or creating a tuple set of your members. The NON EMPTY on columns is unnecessary when you have only one item on the axis. I've combined all of these suggestions below:

with member [measures].[total] as 
[Measures].[m1] + [Measures].[m2] + [Measures].[m3]
select 
[measures].[total] on columns, 
filter (
   nonempty(
      ([dim1].[h1].[h1].members,
       [dim1].[h2].[h2].members,
       [Loss Date].[Date].[Year].members,
       [Dim1].[h3].[h3].members)
      , [measures].[m1]),
, [measures].[total]>100000 and [Measures].[Open File Count]>0) on rows
from
(select [1 Date - Month End].[Month End Date].[Month].&[20120331] on columns 
from [Monthly Summary])

See this for a bit of explanation on the NON EMPTY versus NonEmpty: http://blogs.msdn.com/b/karang/archive/2011/11/16/mdx-nonempty-v-s-nonempty.aspx. In some cases putting a NonEmpty function inside a Filter function can produce a performance hit, sometimes not - you need to test.

The problem might be in a dimension or cube design (storage engine problem) and not in the query (formula engine problem). You can diagnose using the techniques here: http://www.microsoft.com/en-us/download/details.aspx?id=661. The whitepaper was written for SSAS 2005, but still applies to later versions of SSAS.

于 2012-08-21T13:19:31.983 回答
2

您可以使用Having而不是Filter,因为它是在 之后应用的Non Empty,您可能会获得更好的性能(请参阅Chris Webb 的这篇出色的博客文章)。这将是查询的新版本:

with member [measures].[total] as 
[Measures].[m1] + [Measures].[m2] + [Measures].[m3]
select non empty
[measures].[total] on columns, 
non empty 
[dim1].[h1].allmembers
* [dim1].[h2].allmembers
* [Loss Date].[Date].[Year].allmembers
* [Dim1].[h3].allmembers 
having [measures].[total]>100000 and [Measures].[Open File Count]>0 on rows
from [Monthly Summary]
where ([1 Date - Month End].[Month End Date].[Month].&[20120331])
于 2012-08-21T06:59:43.040 回答
1

要减少内存,请订购您的尺寸。

代替:

[dim1].[h1].allmembers
* [dim1].[h2].allmembers
* [Loss Date].[Date].[Year].allmembers
* [Dim1].[h3].allmembers 

利用

[dim1].[h1].allmembers
* [dim1].[h2].allmembers
* [Dim1].[h3].allmembers
* [Loss Date].[Date].[Year].allmembers 

在幕后,SSAS 将内部加入 dim1 成员,外部加入 Loss Date 成员。

于 2012-08-21T09:50:37.107 回答