Hello
I have an Analysis Services performance question:
Scenario:
My Fact table has a column that indicates some value-ID and only one value column. Out of this fact table I'd like to create a cube with two measures, one for each value-ID. So I could either write a query like
Code Snippet
SELECT key1, key2,
sum(case valueID when 'A' then value else null end) as measureA,
sum(case valueID when 'B' then value else null end) as measureB
FROM myFacts
GROUP by key1, key2
Then I'd use this table or view as fact table.
Or I could include the case syntax directly in the measure definitions inside Analysis Services and use the original table.
Does anybody know what's better concerning performance
-regarding cube processing?
-regarding querying the cube?
Are there other things that make one solution the better one?
Hi,
If you use your select statement to load the data into the cube.
-Processing will be slower as it has to execute the case statement
-Querying will be faster
If you read in the values with out the case statement
-Processing will be quicker as it doesn't have to execute the case statement
-Querying will be slower, you will have to create to MDX calculated measures that do the same as you are showing.
If you use your group by select statement, the granularity of your fact is also going to change - is that really what you want?
I would just create two MDX calculated measures, does depend on the size of data I suppose.
CREATE MEMBER CURRENTCUBE.[measures].[measureA] as
([Measures].[Value],[Dimension].[Dimension Key].&)
,non_empty_behavior = [Measures].[Value],VISIBLE = 1;
Might look something like above - ish
Hope that helps,
Matt
|||Hi Matt
Thank you for your reply.
(First I apologize for not having added that I'm using Analysis Services 2000 not 2005.)
Generally I don't want to create a calculated member for each measure becaus calculated members are only calculated during run time but I want to have the measures correct after the cube was processed.
In Analysis Services 2000 I don't have the ability to use a select statement as a source for a fact table. Instead a table or view must exist in the underlying datasource. So there I have the possibility to either create a table or view with the select statement above or I enter the case expression inside the measure definition. So somewhere the case will be executed because having a dimension like "valueID" is not what I want or, wait, ...maybe it could be also a possible solution to have just one measure in the cube and have a valueID dimension... But this leads to more difficult queries and some inconveniances for cube users.
Regards
Chris
|||Hi,
My 2000 skills are a little rusty and weren't perhaps that great in the first place
I would probably create a view, it would allow you to compare A against B or even create a total of A and B if you need to.
Sorry I can't be much help, perhaps someone else will help you.
Cheers
Matt
No comments:
Post a Comment