Search code examples
ssasmdxmultidimensional-cube

MDX Calculated Member Performance Issue


SELECT NON EMPTY {
    [Measures].[Production_Volume]
} ON COLUMNS,
NON EMPTY { (
    [Make].[Make ID].[Make ID].ALLMEMBERS
    * [Model].[Model Hierarchy].[MDL].ALLMEMBERS
    * [Customer].[Customer ID].[Customer ID].ALLMEMBERS
) } ON ROWS
FROM [Model_Cube]

This query is taking 10 min

[Measures].[Production_Volume] is a calculated member in the cube, if I put the definition of this member directly in the query it's taking much lesser time.

WITH MEMBER [Measures].[Production_Volume] AS 
([Measures].[Model Count],
               ([Status].[Status Type].&[T]
                ,[Mode].[Mode Type].&[A])
            ) 
    + Sum(
               ([HYBRID_MODELS]
                ,[Status].[Status Type].&[C]
                ,[Mode].[Mode Type].&[A])
            ,[Measures].[Model Count]
            )
SELECT NON EMPTY {
    [Measures].[Production_Volume]
} ON COLUMNS,
NON EMPTY { (
    [Make].[Make ID].[Make ID].ALLMEMBERS
    * [Model].[Model Hierarchy].[MDL].ALLMEMBERS
    * [Customer].[Customer ID].[Customer ID].ALLMEMBERS
) } ON ROWS
FROM [Model_Cube]

this query is taking 4 sec

Unable to understand the difference between the two, I ran the profiler but couldn't find any difference, except that the first query showed flight recorder snapshot events second query didn't.


Solution

  • The problem was how I created named sets "[HYBRID_MODELS]". I changed them from DYNAMIC to STATIC this helped. Another change I did was replace -{} with the EXCEPT() function. These both changes reduced query time from 30min to 1min!

    Hope this helps someone in need :)