提高MDX查询性能

时间:2018-01-22 14:21:12

标签: ssas mdx

我的查询运行时间过长。

我有一个多维数据集,其中包含[Days Open]和[Days Overdue]的度量。过滤这些度量的任何查询都是导致问题的原因。这是MDX的开始:

WITH  
SET [Measure Filter] 
  AS FILTER( 
       [Event Work Order].[Event Work Order ID].Members, 
     ( ([Measures].[Days Open] >= 1 AND [Measures].[Days Open] <= 250 )  )) 
Member [Measures].[Work Order Measure] AS 
     (SUM([Measure Filter]
        , [Measures].[Work Order Count] ))

创建的度量所依据的基础数据具有记录中每个值的列。我是否可以为逾期天数和开放天数创建维度,然后可以对其进行过滤?如果我这样做会加快查询的执行速度吗?

3 个答案:

答案 0 :(得分:0)

只有我所做的更改才是合并SET的中间步骤,然后只使用元组作为最终测量,但我认为以下几乎只是语法上的修改,对性能没有帮助

WITH  
SET [OrderID set]
  AS FILTER( 
       [Event Work Order].[Event Work Order ID].Members, 
       [Measures].[Days Open] >= 1 
             AND [Measures].[Days Open] <= 250 
       )
MEMBER [Event Work Order].[Event Work Order ID].[All].[OrderID set sum] AS
  SUM([OrderID set])
Member [Measures].[Work Order Measure] AS 
     ([Event Work Order].[Event Work Order ID].[All].[OrderID set sum] 
        , [Measures].[Work Order Count] )

答案 1 :(得分:0)

Try applying NonEmpty function around the Event Work order dimension and Days open Measure.

Could you also simplfy filter to be just <= and remove the AND.

答案 2 :(得分:0)

我创建了一个名为[工作订单天数打开]的新维度,其中包含所有唯一天数开放值。

原始查询是:

WITH  SET [Measure Filter] AS (FILTER( [Event Work Order].[Event Work Order ID].Members, ( ([Measures].[Days Open] >= 10 AND [Measures].[Days Open] <= 250 )  ))) Member [Measures].[Work Order Measure] AS (SUM([Measure Filter], [Measures].[Work Order Count] )) SELECT NON EMPTY { [Measures].[Work Order Measure]  } ON 0, NON EMPTY { (  EXCEPT( [Category Type].[Category Type Name].Members  , [Category Type].[Category Type Name].[All] )   ) } ON 1 FROM [Work Order] WHERE ( {  [Event Start Dates].[Date Key].[20160724] :  [Event Start Dates].[Date Key].[20180124]   })

执行时间 2:31

使用新的Dimension,新查询为:

SELECT NON EMPTY { [Measures].[Work Order Count] } ON 0, 
NON EMPTY { ( EXCEPT( [Category Type].[Category Type Name].Members , [Category Type].[Category Type Name].[All] ) ) } ON 1 
FROM [Work Order] 
WHERE ( { [Event Start Dates].[Date Key].[20160724] : [Event Start Dates].[Date Key].[20180124] }, 
 {[Work Order Days Open].[Days Open].[10] : [Work Order Days Open].[Days Open].[250] } )

执行时间 0:04

正如您所看到的,新维度的引入对查询性能产生了戏剧性影响。