Skip to main content

Order of tables appear in the SQL generated by the MicroStrategy SQL Generation Engine


Order of tables appear in the SQL generated by the MicroStrategy



Most latest generation databases provide the same performance regardless of the order in which the tables are placed in the FROM clause SQL query. Their optimizers take care of choosing the most efficient way of performing the joins. Other databases perform differently producing a different order. This means that a database compiler may choose a different join path that can be more or less efficient.

By default, the MicroStrategy SQL Generation Engine orders the tables in the following way:
  1. Fact Tables
  2. Metric Qualification (MQ) Tables
  3. Relationship Tables
  4. Lookup Tables

But this behavior can be changed by using the 'From Clause Order' VLDB property under the 'Joins' folder. This setting has four values:


Below are the values that the setting may have:
  • Normal FROM clause order as generated by the engine
    This is the default value. It uses the following order:

    1. Fact Tables
    2. MQ Tables
    3. Relationship Tables
    4. Lookup Tables


  • Move last table in normal FROM clause order to the first
    This option moves the last table in the normal order (which is a lookup table) to the beginning of the From clause. This value is useful in some Oracle databases where it may be more efficient for the Fact table not to be the first table in the From clause.

  • Move MQ table in normal FROM clause order to the last (for Redbrick)
    This value orders the MicroStrategy SQL Generation Engine to place the MQ tables at the end of the FROM clause. So the order becomes the following:

    1. Fact Tables
    2. Relationship Tables
    3. Lookup Tables
    4. MQ Tables
  • Reverse FROM clause order as generated by the Engine
    This value reverses the normal order of tables as generated by the MicroStrategy SQL Generation Engine. So the order becomes the following:

    1. Lookup Tables
    2. Relationship Tables
    3. MQ Tables
    4. Fact Tables
Note: The "From Clause Order" VLDB property is intended to control syntax only, not join behavior. Report results should be the same for all values of this setting. If the report uses only inner joins, then the only thing that changes is the table order. One-sided outer joins will switch direction when the From clause order is altered.

For example, a report that performs left outer joins to lookup tables (using the "Preserve all final pass result elements" VLDB property) will generate SQL such as the following:

select   a11.REGION_ID REGION_ID,
   max(a14.REGION_NAME) REGION_NAME,
   a12.CATEGORY_ID CATEGORY_ID,
   max(a13.CATEGORY_DESC) CATEGORY_DESC,
   sum(a11.TOT_DOLLAR_SALES) WJXBFS1
from   STATE_SUBCATEG_REGION_SLS   a11
   left outer join   LU_SUBCATEG   a12
    on    (a11.SUBCAT_ID = a12.SUBCAT_ID)
   left outer join   LU_CATEGORY   a13
    on    (a12.CATEGORY_ID = a13.CATEGORY_ID)

   left outer join   LU_REGION   a14
    on    (a11.REGION_ID = a14.REGION_ID)

group by   a11.REGION_ID,
   a12.CATEGORY_ID
    Moving the last table to the top of the From clause places the joins for the first three tables in parentheses. LU_REGION, formerly last, now appears first and right outer joins to the parenthesized join expression.

    select   a11.REGION_ID REGION_ID,
       max(a14.REGION_NAME) REGION_NAME,
       a12.CATEGORY_ID CATEGORY_ID,
       max(a13.CATEGORY_DESC) CATEGORY_DESC,
       sum(a11.TOT_DOLLAR_SALES) WJXBFS1
    from   LU_REGION   a14
       right outer join
       (STATE_SUBCATEG_REGION_SLS   a11
       left outer join   LU_SUBCATEG   a12
        on    (a11.SUBCAT_ID = a12.SUBCAT_ID)
       left outer join   LU_CATEGORY   a13
        on    (a12.CATEGORY_ID = a13.CATEGORY_ID))

        on    (a11.REGION_ID = a14.REGION_ID)
    group by   a11.REGION_ID,
       a12.CATEGORY_ID
      Both From clauses are functionally identical. This is by design -- the intent of this property is to change the From clause order only, to fit better with a particular database platform's SQL optimizer.

      If it is needed to change the behavior of outer joins, the VLDB properties pertaining to outer joins should be used:

      • Preserve all final pass result elements
      • Preserve all lookup table elements
      • Downward outer join


      Comments

      Popular posts from this blog

      Microstrategy "Error type: Odbc error. Odbc operation attempted

       "Error type: Odbc error. Odbc operation attempted: SQLExecDirect. [HYT00:0: on SQLHANDLE] [MicroStrategy][ODBC Oracle Wire Protocol driver]Timeout expired" is shown when executing reports from Web When users are trying to execute some reports in MicroStrategy web in particular, they may receive the Error ā€œSQL Generation Complete Index out of rangeā€ and ā€œTimeout expiredā€ error as shown below: Possible Causes: One possible cause is that the MicroStrategy Intelligence Server using a cached database connection that was already dropped by the RDBMS. To resolve this: Admin should delete the database connection caches and create a new DSNs in case they are sharing DSNs to connect to different databases. In addition, change the settings for the ā€˜Connection lifetimeā€™ and the ā€˜Connection idle time outā€™.  Follow the steps below to perform the mentioned changes and verify the report after each step and some of the settings require i-server r...

      Case functions Microstrategy

      Ca se functions Microstrategy Case functions return specified data in a SQL query based on the evaluation of user-defined conditions. In general, a user specifies a list of conditions and corresponding return values. Case This function evaluates multiple expressions until a condition is determined to be true, then returns a corresponding value. If all conditions are false, a default value is returned.  Case  can be used for categorizing data based on multiple conditions. This is a single-value function. Syntax Case ( Condition1 ,  ReturnValue1 ,  Condition2 , ReturnValue2 ,...,  DefaultValue ) Example Case(([Total Revenue] < 300000), 0, ([Total Revenue] < 600000), 1, 2) sum(Case (Day@DESC in (ā€œSatā€,ā€Sunā€), Sales, 0) {~+} Sum(Case(Category@DESC In("Books","Electronics"),Revenue,0)){~+} CaseV (case vector) CaseV  evaluates a single metric and returns different values according to the results. It can be used to perfo...

      Microstrategy Dashboard performance improvements steps

      Microstrategy  Dashboard performance improvements steps: Many times, causes of poor performance can be simplified to specific components. To troubleshoot performance issues, users must identify these components, then make the appropriate modifications to the environment and/or to the MicroStrategy dashboard to reduce bottlenecks. Dashboard execution stages can be represented below: MicroStrategy Intelligence Server When an end user makes a  Document Execution Request  through any client (a web browser via MicroStrategy Web, the MicroStrategy Desktop/Developer client, the MicroStrategy Mobile app, or the MicroStrategy Office client), the request is sent to the MicroStrategy Intelligence Server, which processes the request and prepares the response. The MicroStrategy Intelligence Server will execute all children datasets on the dashboard by either generating SQL and running this against the data warehouse, or by fetching data from a cache. The Inte...

      MicroStrategy URL API Parameters

      MicroStrategy URL Structure The following table summarizes the root URL structure used for every request to MicroStrategy Web. Environment Main Application URL Administration URL J2EE http://webserver/MicroStrategy/servlet/mstrWeb http://webserver/MicroStrategy/servlet/mstrWebAdmin .NET http://webserver/MicroStrategy/asp/Main.aspx http://webserver/MicroStrategy/asp/Admin.aspx Every request sent to MicroStrategy Web calls a central controller. Parameters are appended to  Main.aspx  or  mstrWeb  (in a .NET and J2EE environment, respectively) to indicate to the controller how the request should be internally forwarded and handled. The following examples show a URL for accessing a MicroStrategy folder when the user does not have an existing session. The URL contains not only the parameters needed to connect to MicroStrategy Web, but also the parameters needed to log on and create a session. J2EE environment: <a href="http:...

      Microstrategy Document Autotext macros:

      Autotext  code/macros in  Microstrategy Document/dashboard This is a list of the available auto text macros that the Report Services Document engine recognizes. The following auto text codes allow you to add  document variable information to your document. These auto text codes are automatically replaced by information about the document. Auto text codes for MSTR document/dashboard:  AUTOTEXT DESCRIPTION   {&PAGE}  Display the current page.  {&NPAGES}  Display the total number of pages.  {&DATETIME}  Display the current date and time.  {&USER}  Display the user name that is executing the Report Services Document.  {&DOCUMENT}  Display the document name.  {&DOCUMENTID}  Display the document ID.  {&DESCRIPTION}  Display the document description.  {&PROJECT}  Display the project name.  {&EXECUTIONTIME}  Dis...

      Settings for Outer Join between metrics in MicroStrategy

      Settings for Outer Join between metrics in MicroStrategy MicroStrategy adopts multi-pass logic to determine the execution plan for a report. This means that every metric is evaluated in separate SQL passes. Outer Joins come into play when MicroStrategy Engine merges the results from all SQL passes into one report. For a multi-pass report, different Outer Join behaviors can give the user completely different results. In addition, report metrics can be of different types which can, in some cases, influence the result of the outer join. In MicroStrategy, there are two settings that users can access to control Outer Join behavior : Formula Join Type and Metric Join Type . Metric Join Type: VLDB Setting at Database Instance Level Report and Template Levels Report Editor > Data > Report Data Options Metric Level   Metric editor > Tools > Metric Join Type Control Join between Metrics Formula Join Type: Only at Compound/Split...

      Control the display of null and zero metric values

      Show   Control the display of null and zero metric values in a grid report You can determine how to display or hide rows and columns in a grid report that consist only of null or zero metric values. You can have MicroStrategy hide the rows and columns in the following ways: Hide rows and columns that consist only of null metric values Hide rows and columns that consist only of zero metric values Hide rows and columns that consist only of null or zero metric values (default) Once you have defined how MicroStrategy hides null and zero metric values in the grid, you can quickly show or hide the grid using the Hide Nulls/Zeros option in the Data menu, as described below, or by clicking the  Hide Nulls/Zeros  icon  in the Data toolbar. To determine how null and zero metric values are displayed or hidden in a grid report Open the report in Edit mode. From the  Tools  menu, select  Report Options . The Report Options...

      Retrieve a list of user groups and the associated users in MicroStrategy Developer 9.x / 10.x

      Retrieve a list of user groups and the associated users in MicroStrategy Developer Follow the steps below to create a list of all groups and the users in each group: In MicroStrategy Developer 9.x, select 'Project Documentation' from the Tools menu to start the wizard. Select any project that is in the project source that contains the users and groups and click Next. Select only Configuration Objects for documentation. Uncheck the 'Basic Properties' object category from the next screen, as shown below: Then select only 'User Group' under the Configuration Objects section and only 'Groups' and 'Members' under the Definition section, as shown below: Go through the rest of the wizard, and open the resulting documentation. After navigating down to the User Groups, the documentation should look similar to the following image: This page shows every group, any child groups, and all members of each group.

      Prompt-in-prompt(Nested Prompts) in Microstrategy

      Prompt-in-prompt(Nested Prompts) in  Microstrategy Nested prompts allows you to create one prompt based on the other and other bases on another, nested prompts allows us to prompt the highest level(Like year) to middle level(like Quarter, then to the low level(like Month). Here you can see how to  create a 3-level deep nested prompt that will prompt the user to select a year, then a quarter within that year, then a month within that quarter. Prompt-in-prompt is a feature in which the answer to one prompt is used to define another prompt. This feature is only implemented for element list prompts . The following procedure describes how to achieve this: Create the highest level filter. This is a filter which contains a prompt on an attribute element list. Create a filter on the attribute "Year." Click "prompt on attribute element list" and click "Next" through the rest of the screens to accept the default values. Do not set any additio...
      Star schemas and aggregate (or summary) fact tables Aggregate tables can further improve query performance by reducing the number of rows over which higher-level metrics must be aggregated.  However, the use of aggregate tables with dimension tables is not a valid physical modeling strategy. Whenever aggregation is performed over fact data, it is a general requirement that tables joined to the fact table must be at the same attribute level or at a higher level. If the auxiliary table is at a lower level, fact rows will be replicated prior to aggregation and this will result in inflated metric values (also known as "multiple counting"). With the above Time dimension table, a fact table at the level of Day functions correctly because there is exactly one row in DIM_TIME for each day. To aggregate the facts to the level of Quarter, it is valid to join the fact table to the dimension table and group by the quarter ID from the dimension table. Sql select DT...