Analysis on performance comparison between DAX and MDX

Once I was asked to find out reason for difference in Performance for DAX and MDX on Tabular Model. For that i went through many links, post and ebook materials. Below are the consolidated observations.

Query Execution of DAX and MDX:

  1. We need to understand high level query execution plan first for DAX or MDX in Tabular Model. Below screenshot explain the same (for any query on Tabular Model):
  2. We cannot find any difference for the MDX and DAX query execution as per above figure.
  3. Difference starts with transform of query from In-Memory Query mode to xVelocity Engine. Below screenshot shows how:Note: MDX is not working on DirectQuery mode.
  4. Execution of queries is done as explained below:
    1. When a DAX query is sent to a Tabular Model, it generate DAX query plan and that is transformed into commands sent to xVelocity Engine.
    2. MDX query is analysed by the MDX Formula Engine, which calls the DAX Formula Engine to solve DAX measures (calculated measures in Tabular model) and generates a query plan that performs requests to the xVelocity Storage Engine.
  5. Thus, MDX query is not converted into an equivalent DAX query, it generates one or more commands to the DAX Formula Engine and then to the xVelocity Storage Engine in order to retrieve values and evaluate the DAX measures it require.
  6. So even when same result is given by DAX and MDX (i.e. when we call it DAX equivalent to MDX), different internal operations can be performed with different performances.
  7. About the query plan, each time when the DAX Formula Engine is called to evaluate a DAX expression, a pair of DAX Query Plan events are generated (i.e. a logical plan event and a physical plan event, but let not discuss this in detail. Detailed information can be viewed here).
    But an MDX query may produce any number of pairs of events depending on how many times the MDX Formula Engine has to call into the DAX Formula Engine (for DAX measure as explained above).
  8. Both MDX and DAX Formula engine perform single threaded operations
  9. xVelocity engine can work on multi-threaded operation. So from above two points, it’s clear to push as much as request on xVelocity engine rather than Formula Engines. I think it will increase performance and it depends upon simpler queries. As the complexity of queries will increase, Formula Engine will be more busy than xVelocity.

From above discussion points, I tried to consolidate it as:

  1. There is no direct way to say completely that DAX is better than MDX in performance or vice versa.
  2. As MDX query uses DAX Formula engine to solve DAX measures, it may effect performance in any of two scenarios:
    1. If measure involve complex logic
    2. If many measures are called together (Refer point 6)
  3. Huge data will not matter in performance, it will be time of converting DAX measure for MDX query by DAX Formula Engine. (Refer point 10)
Advertisements

Posted on August 26, 2012, in BI Semantic Tabular Model, DAX, MDX and tagged , , , , , , , . Bookmark the permalink. 3 Comments.

  1. In your last sentence you refer to point 10 and your list has only 9 points.

    What is this point 10 about, I am really interested about this statement about large amount of data.

  2. Is there a way to see and display nicely the DAX/MDX query execution plans like for the relational database engine?

    • OMG!! what a mistake. Sorry and thanks for catching it. Its actually point number 3 from very top.
      In case of huge data or small data, extraction is not dependent on any query type. Only issue is if MDX is complicated it will take more time to convert into DAX. In point 3 it shows where conversion take.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: