I have a MDX query, and I am executing it on Mondrian engin.
WITH
MEMBER [Measures].[HC Threshold] AS
Val(StrToMember("[HC Threshold].[HC Threshold].[All].[25000]").Name)
,FORMAT_STRING = "$#,0"
SET ClaimantsSet AS
Order
(
Filter
(
NonEmpty
(
[Count Of Claimants].[Count Of Claimants].[ID].MEMBERS
,{[Measures].[Plan Paid]}
)
,
[Measures].[Plan Paid] > [Measures].[HC Threshold]
)
,[Measures].[Plan Paid]
,desc
)
MEMBER [Measures].[ICD9Desc] AS
Tail
(
Order
(
NonEmpty
(
[ICD-9 Primary Diagnosis Code].[Diagnosis Code].[ID].MEMBERS
,{[Measures].[Plan Paid]}
)
,[Measures].[Plan Paid]
,asc
)
).Item(0).Item(0).Properties("Short Description")
SELECT
{[Measures].[ICD9Desc]} ON 0
,NON EMPTY
{ClaimantsSet} ON 1
FROM [Combined Claims]
WHERE
(
[Insights Group Structure].[Insights Group Structure].[Insights Report ID].&[1706].FirstChild
/* StrToMember("No HRA",CONSTRAINED), */
,[Plan Period].[Plan Period].[Date Year Quart].&[20152].Lead(4)
,[Claim Status].[Claim Status].[Claim Status ID].&[1]
);
when I execute it it fails, due to time out.
but when I execute,
WITH
MEMBER [Measures].[HC Threshold] AS
Val(StrToMember("[HC Threshold].[HC Threshold].[All].[25000]").Name)
,FORMAT_STRING = "$#,0"
SET ClaimantsSet AS
Order
(
Filter
(
NonEmpty
(
[Count Of Claimants].[Count Of Claimants].[ID].MEMBERS
,{[Measures].[Plan Paid]}
)
,
[Measures].[Plan Paid] > [Measures].[HC Threshold]
)
,[Measures].[Plan Paid]
,desc
)
SELECT
NON EMPTY
{ClaimantsSet} ON 0
FROM [Combined Claims]
WHERE
(
[Insights Group Structure].[Insights Group Structure].[Insights Report ID].&[1706].FirstChild
/* StrToMember("No HRA",CONSTRAINED), */
,[Plan Period].[Plan Period].[Date Year Quart].&[20152].Lead(4)
,[Claim Status].[Claim Status].[Claim Status ID].&[1]
);
which is only set on column, it runs successfully in 3 min.
When I looked up for SQL log for first query I found that, ICD9Desc value is being calculated for every tuple of set 'ClaimantSet', so if there are 300 tuples in set claimantSet, ICD9Desc is getting calculated 300 times, and so 300 SQL queries are getting generated. And because of this it takes time and time out.
Is there any solution to avoid SQL queries getting generated that many times, can I optimize my MDX query or Schema in Mondrian?
If you take the Order out of the measure do you still get the same functionality and does it run quicker?