dbTalk Databases Forums  

MDX: suprisingly poor query performace

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


Discuss MDX: suprisingly poor query performace in the microsoft.public.sqlserver.olap forum.



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

Default MDX: suprisingly poor query performace - 04-13-2005 , 06:51 AM






Hi All,

Please explain the difference in execution duration for the following
2 logically equivalent queries to FoodMart 2000. The first query
takes 1 sec to execute at my site, the 2nd query takes 75 sec.

with member [Customers].[CM] as '[Customers].[Name].[Alice Cantrell]'
SELECT { [Customers].[CM] } ON COLUMNS ,
NON EMPTY { { [Store].[Store Name].Members } * {
[Product].[Product Name].Members } } ON ROWS
FROM [Sales]
where ([Measures].[Unit Sales])


with member [Customers].[CM] as '[Customers].[Name].[Amy
Petranoff].PrevMember'
SELECT { [Customers].[CM] } ON COLUMNS ,
NON EMPTY { { [Store].[Store Name].Members } * {
[Product].[Product Name].Members } } ON ROWS
FROM [Sales]
where ([Measures].[Unit Sales])

Reply With Quote
  #2  
Old   
Mosha Pasumansky [MS]
 
Posts: n/a

Default Re: MDX: suprisingly poor query performace - 04-13-2005 , 12:24 PM






I replied to Andrew in sql.ru forum where he originally asked this question.
I am too surprised by such a big difference in performance, especially given
that the space described by the crossjoin on rows is not very big - only
37440 cells. For your reference - here is the thread with the discussion
http://www.sql.ru/forum/actualthread.aspx?tid=175595

--
==============================*=================== =
Mosha Pasumansky - http://www.mosha.com/msolap
Analysis Services blog at http://www.sqljunkies.com/WebL*og/mosha
Development Lead in the Analysis Server team
All you need is love (John Lennon)
Disclaimer : This posting is provided "AS IS" with no warranties, and
confers no rights.
==============================*=================== =
"Chris Webb" <OnlyForPostingToNewsgroups (AT) hotmail (DOT) com> wrote

Quote:
Good question, I can repro and I'm surprised that I've never seen this
before. The only thing I can think of is that in the first query the query
optimiser can do something clever because it realises the calculated
member
is the same as a real member, something it can't do in the second query.
Mosha, if you're reading....???

"Andrew" wrote:

Hi All,

Please explain the difference in execution duration for the following
2 logically equivalent queries to FoodMart 2000. The first query
takes 1 sec to execute at my site, the 2nd query takes 75 sec.

with member [Customers].[CM] as '[Customers].[Name].[Alice Cantrell]'
SELECT { [Customers].[CM] } ON COLUMNS ,
NON EMPTY { { [Store].[Store Name].Members } * {
[Product].[Product Name].Members } } ON ROWS
FROM [Sales]
where ([Measures].[Unit Sales])


with member [Customers].[CM] as '[Customers].[Name].[Amy
Petranoff].PrevMember'
SELECT { [Customers].[CM] } ON COLUMNS ,
NON EMPTY { { [Store].[Store Name].Members } * {
[Product].[Product Name].Members } } ON ROWS
FROM [Sales]
where ([Measures].[Unit Sales])




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

Default Re: MDX: suprisingly poor query performace - 04-13-2005 , 07:59 PM



Could this have something to do with how well NON EMPTY can be optimized
in the 2 cases (since the result set is sparse: only 20 non-empty values
out of 37,440)? This version of the second query, using
NonEmptyCrossJoin(), seems to be only slightly slower than the 1st
query:

Quote:
with member [Customers].[CM] as
'[Customers].[Name].[Amy Petranoff].PrevMember'
SELECT { [Customers].[CM] } ON COLUMNS ,
NonEmptyCrossJoin( [Store].[Store Name].Members,
[Product].[Product Name].Members,
{[Customers].[Name].[Amy Petranoff].PrevMember}, 2) ON ROWS
FROM [Sales]
where ([Measures].[Unit Sales])
Quote:

- Deepak

Deepak Puri
Microsoft MVP - SQL Server

*** Sent via Developersdex http://www.developersdex.com ***


Reply With Quote
  #4  
Old   
Mosha Pasumansky [MS]
 
Posts: n/a

Default Re: MDX: suprisingly poor query performace - 04-13-2005 , 09:07 PM



No - it cannot be it, since both queries use calculated member. The only
difference that I noted - was the same as Chris noted - static vs. dynamic
binding. But it cannot explain such a huge difference.
And even for the slowest iteration - it should not take 75 seconds to
iterate 37000 cells.

--
==============================*=================== =
Mosha Pasumansky - http://www.mosha.com/msolap
Analysis Services blog at http://www.sqljunkies.com/WebL*og/mosha
Development Lead in the Analysis Server team
All you need is love (John Lennon)
Disclaimer : This posting is provided "AS IS" with no warranties, and
confers no rights.
==============================*=================== =
"Deepak Puri" <deepak_puri (AT) progressive (DOT) com> wrote

Quote:
Could this have something to do with how well NON EMPTY can be optimized
in the 2 cases (since the result set is sparse: only 20 non-empty values
out of 37,440)? This version of the second query, using
NonEmptyCrossJoin(), seems to be only slightly slower than the 1st
query:


with member [Customers].[CM] as
'[Customers].[Name].[Amy Petranoff].PrevMember'
SELECT { [Customers].[CM] } ON COLUMNS ,
NonEmptyCrossJoin( [Store].[Store Name].Members,
[Product].[Product Name].Members,
{[Customers].[Name].[Amy Petranoff].PrevMember}, 2) ON ROWS
FROM [Sales]
where ([Measures].[Unit Sales])



- Deepak

Deepak Puri
Microsoft MVP - SQL Server

*** Sent via Developersdex http://www.developersdex.com ***



Reply With Quote
  #5  
Old   
Mosha Pasumansky [MS]
 
Posts: n/a

Default Re: MDX: suprisingly poor query performace - 04-14-2005 , 01:16 PM



OK - given that I have the luxury of being able to debug the code to find
out what's going on - I did exactly that. I discovered, that this is simply
a bug which affects performance of PrevMember in this scenario, degrading to
n^k algorithm where n is number of customers and k is number of tuples on
the ROWS axis. The bug is not fixed in SP4, but I verified with Yukon - that
Yukon chooses correct query plan and finishes this query instantly.

--
==============================*=================== =
Mosha Pasumansky - http://www.mosha.com/msolap
Analysis Services blog at http://www.sqljunkies.com/WebL*og/mosha
Development Lead in the Analysis Server team
All you need is love (John Lennon)
Disclaimer : This posting is provided "AS IS" with no warranties, and
confers no rights.
==============================*=================== =
"Mosha Pasumansky [MS]" <moshap (AT) online (DOT) microsoft.com> wrote

Quote:
No - it cannot be it, since both queries use calculated member. The only
difference that I noted - was the same as Chris noted - static vs. dynamic
binding. But it cannot explain such a huge difference.
And even for the slowest iteration - it should not take 75 seconds to
iterate 37000 cells.

--
==============================*=================== =
Mosha Pasumansky - http://www.mosha.com/msolap
Analysis Services blog at http://www.sqljunkies.com/WebL*og/mosha
Development Lead in the Analysis Server team
All you need is love (John Lennon)
Disclaimer : This posting is provided "AS IS" with no warranties, and
confers no rights.
==============================*=================== =
"Deepak Puri" <deepak_puri (AT) progressive (DOT) com> wrote in message
news:uSOB80IQFHA.2972 (AT) TK2MSFTNGP14 (DOT) phx.gbl...
Could this have something to do with how well NON EMPTY can be optimized
in the 2 cases (since the result set is sparse: only 20 non-empty values
out of 37,440)? This version of the second query, using
NonEmptyCrossJoin(), seems to be only slightly slower than the 1st
query:


with member [Customers].[CM] as
'[Customers].[Name].[Amy Petranoff].PrevMember'
SELECT { [Customers].[CM] } ON COLUMNS ,
NonEmptyCrossJoin( [Store].[Store Name].Members,
[Product].[Product Name].Members,
{[Customers].[Name].[Amy Petranoff].PrevMember}, 2) ON ROWS
FROM [Sales]
where ([Measures].[Unit Sales])



- Deepak

Deepak Puri
Microsoft MVP - SQL Server

*** Sent via Developersdex http://www.developersdex.com ***





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

Default Re: MDX: suprisingly poor query performace - 04-14-2005 , 03:49 PM



Mosha, thanks for clearing up the mystery! I for one would not have
guessed that the size of the Customers dimension (> 10 K members) was a
factor; though, now that you mentioned it, a query with Gender is much
faster:

Quote:
with member [Gender].[CM] as '[Gender].[M].PrevMember'
SELECT { [Gender].[CM] } ON COLUMNS ,
NON EMPTY { { [Store].[Store Name].Members } * {
[Product].[Product Name].Members } } ON ROWS
FROM [Sales]
where ([Measures].[Unit Sales])
Quote:

- Deepak

Deepak Puri
Microsoft MVP - SQL Server

*** Sent via Developersdex http://www.developersdex.com ***


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.