dbTalk Databases Forums  

RE: MDX function AGGREGATE very slow, please help

microsoft.public.sqlserver.olap microsoft.public.sqlserver.olap


Discuss RE: MDX function AGGREGATE very slow, please help in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Bill Cheng
 
Posts: n/a

Default RE: MDX function AGGREGATE very slow, please help - 08-25-2004 , 08:27 AM






Hi,

Could you let me know why you use Aggregate function in this way? Aggregate
function returns a calculated value using the appropriate aggregate
function. Normal usage is as below:-

WITH MEMBER Geography.Total AS 'AGGREGATE({USA, France})'
SELECT {Measures.SumSales, Measures.MaxSales} ON COLUMNS,
{USA, France, Total} ON ROWS
FROM SalesCube
WHERE ([1998])

Using in WHERE clause is strange. Can you try not using AGGREGATE function
in WHERE clause? Does it work the same?


Bill Cheng
Microsoft Online Partner Support
Get Secure! – www.microsoft.com/security
This posting is provided “as is” with no warranties and confers no rights.
--------------------
Quote:
Thread-Topic: MDX function AGGREGATE very slow, please help
thread-index: AcSJ0KG92cmD6tZ8QAGkLVoz4BJBEA==
X-WBNR-Posting-Host: 80.132.76.26
From: "=?Utf-8?B?SmFtZXM=?=" <news (AT) att (DOT) com
Subject: MDX function AGGREGATE very slow, please help
Date: Tue, 24 Aug 2004 04:51:03 -0700
Lines: 52
Message-ID: <369B4FE7-2C60-4219-92B3-E61A2DB667DE (AT) microsoft (DOT) com
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.sqlserver.olap
NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
Xref: cpmsftngxa10.phx.gbl microsoft.public.sqlserver.olap:52962
X-Tomcat-NG: microsoft.public.sqlserver.olap

I have the same MDX query in 2 different versions:

The Aggregate version, which takes 10 seconds to run:
with member Store.Standard.AllowedStores as
'Aggregate(descendants([Store].Standard.[Southwest],Store))'
select
{[Measures].[Units], [Measures].[Net Sales]} on columns,
{ TopCount(crossjoin({[Product Style].members},{[Product
Division].[Drinks]}), 20,[Measures].[Units]),
TopCount(crossjoin({[Product Style].members},{[Product
Division].[Snacks]}), 20,[Measures].[Units]),
TopCount(crossjoin({[Product Style].members},{[Product
Division].[Food]}),
20,[Measures].[Units])
} on rows
from [Sale]
where ( [Store].[Standard].AllowedStores ,
[Time].[Marketing].[Week].&[05-Jul-04])

The "without aggregate version" is as follows. Please note that the "with
member" is still there, but the member isn't used in the query. The only
difference is in the WHERE slice. This version gives exactly the same
results
but runs in less than a second:

with member Store.Standard.AllowedStores as
'Aggregate(descendants([Store].Standard.[Southwest],Store))'
select
{[Measures].[Units], [Measures].[Net Sales]} on columns,
{ TopCount(crossjoin({[Product Style].members},{[Product
Division].[Drinks]}), 20,[Measures].[Units]),
TopCount(crossjoin({[Product Style].members},{[Product
Division].[Snacks]}), 20,[Measures].[Units]),
TopCount(crossjoin({[Product Style].members},{[Product
Division].[Food]}),
20,[Measures].[Units])
} on rows
from [Sale]
where ( [Store].[Standard].Southwest,
[Time].[Marketing].[Week].&[05-Jul-04])

I need to use the Aggregate (I believe) because in a next version of the
query, I will intersect the descendants of Southwest with the stores that
the
user is allowed to see, like in:

with member Store.Standard.AllowedStores as
'Aggregate(Intersect(descendants([Store].Standard.[Southwest],Store),
{descendants([Store].Standard.[SFO],Store)}))'

for the manager of the SFO shop.

Am I doing something wrong? How could I improve performance? How does the
Aggregate version takes 10 times more processing? Is there a way to slice
on
a set of stores without using the Aggregate function?




Reply With Quote
  #2  
Old   
Deepak Puri
 
Posts: n/a

Default RE: MDX function AGGREGATE very slow, please help - 08-25-2004 , 09:32 PM






Aggregate is a standard way to reference a set in the slicer/where
clause. But how many members are in:

descendants([Store].Standard.[Southwest],Store))

versus how many members are expected to be selected? If the latter
number is much smaller, than the performance may be much better than
what you are measuring - after all, Aggregate() has to apply the
appropriate function (Sum, Count, etc) across the set of members at
query time.

If the selected set is large, then the only optimization that comes to
mind is to design a hierarchy where substantial subsets are already
pre-aggregated.

If the only aggregate functions are Sum and Count, then a complement set
approach is possible, ie. if A = All - B, then Sum(A) = Sum(All) -
Sum(B) (B much smaller than A).


- Deepak

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Reply With Quote
  #3  
Old   
John Desch [MS]
 
Posts: n/a

Default RE: MDX function AGGREGATE very slow, please help - 09-03-2004 , 05:13 PM



Calculated members are always calculated at run-time as the cell values are
displayed or requested. The reason for the difference in perfomance is that
in the first query, the calculated member is referenced in the slicer.
Since the calculated member is referenced in the slicer, the value of the
calculated member is calculated for the each of the axes intersection. In
the second query, the calculated member is never referenced and therefore
not calculated.

One approach I've seen to this type of issue is to create a named set then
create the calculated member using the named set. The query would be a
little more involved, something like the following:

WITH set SLICER_SET_1 as 'descendants([Store].Standard.[Southwest],Store)'
MEMBER Store.Standard.AllowedStores AS ' AGGREGATE( SLICER_SET_1) ',
SOLVE_ORDER = 0
select
{[Measures].[Units], [Measures].[Net Sales]} on columns,
{ TopCount(crossjoin({[Product Style].members},{[Product
Division].[Drinks]}), 20,[Measures].[Units]),
TopCount(crossjoin({[Product Style].members},{[Product
Division].[Snacks]}), 20,[Measures].[Units]),
TopCount(crossjoin({[Product Style].members},{[Product
Division].[Food]}),
20,[Measures].[Units])
} on rows
from [Sale]
where ( [Store].[Standard].AllowedStores ,
[Time].[Marketing].[Week].&[05-Jul-04])

The big question is going to be the number of descendants that the
[Store].[Standard].[Southwest] member has at the [Store].[Standard].[Store]
level. If there are only one or two, there shouldn't be a major performance
difference. On the otherhand, if there are a few hundred descendants, the
calculated member would involve hundreds of core calls which would slow
performance.

Regards,

John Desch, MCDBA, MCSD
Microsoft SQL Analysis Services Support

This posting is provided “AS IS”, with no warranties, and confers no rights.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.