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:
- 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):
- We cannot find any difference for the MDX and DAX query execution as per above figure.
- 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.
- Execution of queries is done as explained below:
- 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.
- 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.
- 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.
- 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.
- 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).
- Both MDX and DAX Formula engine perform single threaded operations
- 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:
- There is no direct way to say completely that DAX is better than MDX in performance or vice versa.
- As MDX query uses DAX Formula engine to solve DAX measures, it may effect performance in any of two scenarios:
- If measure involve complex logic
- If many measures are called together (Refer point 6)
- 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)
Posted on August 26, 2012, in BI Semantic Tabular Model, DAX, MDX and tagged DAX query Engine, DAX Query plan, DAX Xvelocity engine, MDX Query Plan, MDX vs DAX, Vertipaq, Vertipaq Engine, XVelocity. Bookmark the permalink. 3 Comments.