|Unnecessary All Members and Performance Problems|
|Written by Chris Webb|
|Thursday, 27 December 2012 21:29|
Reposted from Chris Webb's blog with the author's permission.
Maybe an obscure problem, this one, but worth recording nonetheless. The other week I was performance tuning some queries on a customer's SSAS 2008R2 instance and came across a very strange issue related to the presence of unnecessary All Members in tuples. In this case it was in machine-generated MDX but it's certainly the case the people new to MDX often include All Members in tuples when they are not actually needed; it's a not good idea to do this because it can sometimes have unexpected effects as a result of attribute overwrite and because, as I found, it can also cause severe performance problems too.
The problem can be reproduced very easily against Adventure Works on the Customer dimension. Consider the following query that returns a list of customers who bought more than $1000 of goods in 2003:
Pretty straightforward, and it returns instantly on my laptop as I'd expect. However, adding the All Member from the City hierarchy into the tuple used in the filter() function makes the query run very slowly indeed (I killed it after several minutes):
The All Member here isn't necessary at all; it won't affect how the filter works or the set returned at all. Looking in Profiler it seems as though its presence triggers cell-by-cell mode, which is the cause of the awful performance. Interestingly, the performance got worse the more attributes were on the hierarchy - deleting attributes, even when they weren't used in the query, improved query performance. I'm told the problem could be the result of attribute decoding (which Mosha referred to here, but which I don't know much else about) as a result of attribute overwrite
Anyway in my case it wasn't possible to change the MDX because it was being generated by a client tool - the All Member was there because the City hierarchy was being used as a parameter in the query, although in this case nothing had been selected on it. There was a workaround that I found though: it turns out the problem does not occur for user hierarchies that include the key attribute as their lowest level. So, I renamed the City attribute, hid it, and then created a new user hierarchy called City that had Customer as its lowest level:
With this done, both of the queries above return instantly.
Latest Author Articles
- A Closer Look At Power Query/SSAS Integration
- Bidirectional Relationships And Many-To-Many In The Power BI Designer
- MDX Solve Order, SCOPE_ISOLATION and the Aggregate() function
- Counting Customers Who Have Bought All Selected Products
- Power Pivot / Power Query Read-Only Connection Problems In Excel 2013 - And What To Do About Them