[Mondrian] Unnecessary sorting in axis loading?

Eric McDermid mcdermid at stonecreek.com
Fri May 1 16:36:05 EDT 2009

Marc and I have noticed that sorts appear to be executed multiple  
times over the course of executing a query, and are wondering if some  
of those executions are unnecessary.

Consider the following MDX query:

WITH MEMBER [Measures].[Store Sales Last Period] AS
   ([Measures].[Store Sales], Time.PrevMember)
   {[Measures].[Store Sales Last Period]} on columns,
   {TopCount([Product].[Product Department].members, 5, [Measures]. 
[Store Sales Last Period])} on rows
FROM Sales
WHERE ([Time].[1998])

Initially, as the axes are being determined, the sort is called as a  
result of calling loadMembers() on each of the 2 axes (rows and  
columns).  Later, as the RolapAxis is actually being constructed, the  
sort is called as a downstream consequence of evalExecute().

Obviously, the last sort needs to happen in order to produce the right  
results, but if the purpose of the first pass through the axes is to  
make sure all of the members are loaded, then sorting at that point  
seems like unnecessary overhead that we might be able to eliminate,  
since even without sorting all of them will get loaded.

Is there any reason we need to execute sorts prior to building the  
RolapAxis, or does it make sense for us to look for ways to avoid it?

  -- Eric

More information about the Mondrian mailing list