EducationSoftwareStrategy.com
StrategyCommunity

Knowledge Base

Product

Community

Knowledge Base

TopicsBrowse ArticlesDeveloper Zone

Product

Download SoftwareProduct DocumentationSecurity Hub

Education

Tutorial VideosSolution GalleryEducation courses

Community

GuidelinesGrandmastersEvents
x_social-icon_white.svglinkedin_social-icon_white.svg
Strategy logoCommunity

© Strategy Inc. All Rights Reserved.

LegalTerms of UsePrivacy Policy
  1. Home
  2. Topics

KB17902: How to force a query to filter against a smaller lookup table when more than one lookup table is available in MicroStrategy Engine 9.x-10.x


Community Admin

• Strategy


This example uses the Strategy Tutorial project.
 
Consider a report with the Quarter and Day attributes, the metric Revenue and filtered on Year = 2006, as shown below:
 

ka04W000000OcaVQAS_0EM440000002Ewt.jpeg

 
The report generates the following SQL:
 
select a12.QUARTER_ID QUARTER_ID,
max(a13.QUARTER_DESC) QUARTER_DESC,
a11.DAY_DATE DAY_DATE,
sum(a11.TOT_DOLLAR_SALES) Revenue
from DAY_CTR_SLS a11
join LU_DAY a12
on (a11.DAY_DATE = a12.DAY_DATE)
join LU_QUARTER a13
on (a12.QUARTER_ID = a13.QUARTER_ID)
where a12.YEAR_ID in (2006)
group by a12.QUARTER_ID,
a11.DAY_DATE
Note that the Where clause is evaluating the filter (Year = 2006) by performing a comparison against LU_DATE, which is a larger table than LU_QUARTER. In most databases, keeping filter qualifications as "close" as possible to the fact table (in terms of join paths) yields optimal performance. However, some databases may execute the query more efficiently if the filter is instead qualified against LU_QUARTER.
 
To force the Engine to compare against LU_QUARTER, users can use relationship filtering to force the query into two passes.
 
To accomplish this, replace the existing filter from Year In List (2006) filter with a relationship filter by following the steps below:
 

  • Choose 'Add a Set qualification' and click on 'OK', as shown below:
ka04W000000OcaVQAS_0EM440000002Ewr.jpeg
  • Choose 'Type = Relationship', 'Output Level = Year', 'Filter = Year In List(2006)', and 'Relate By = LU_QUARTER', as shown below:
ka04W000000OcaVQAS_0EM440000002Ewo.jpeg
  • Click on 'Advanced…' and uncheck 'Also apply this qualification independently of the relationship filter', as shown below:
ka04W000000OcaVQAS_0EM440000002Ewm.jpeg

After running the report with the new filter, the SQL appears as follows:
 
select a12.QUARTER_ID QUARTER_ID,
max(a13.QUARTER_DESC) QUARTER_DESC,
a11.DAY_DATE DAY_DATE,
sum(a11.TOT_DOLLAR_SALES) Revenue
from DAY_CTR_SLS a11
join LU_DAY a12
on (a11.DAY_DATE = a12.DAY_DATE)
join LU_QUARTER a13
on (a12.QUARTER_ID = a13.QUARTER_ID)
where ((a12.YEAR_ID)
in (select r11.YEAR_ID
from LU_QUARTER r11
where r11.YEAR_ID in (2006)))
group by a12.QUARTER_ID,
a11.DAY_DATE
Note that the filter qualification now occurs in a subquery and is performed against the smaller LU_QUARTER table.
 
 


PanelsResult CodeDescription0Success-1General error.-2Invalid mode.-3Required data not found in the Setup.iss file.-4Not enough memory available.-5File does not exist.-6Cannot write to the response file.-7Unable to write to the log file.-8Invalid path to the InstallShield Silent response (.iss) file.-9Not a valid list type (string or number).-10Data type is invalid.-11Unknown error during setup.-12Dialog boxes are out of order.-51Cannot create the specified folder.-52Cannot access the specified file or folder.-53Invalid option selected.Indicator ValueType of export1Excel with Formatting2PDF3Excel with Plain Text (OR) CSV (OR) Plain Text12Export to Flash using MHT as container**13Export to Flash using PDF as container**BeforeAfter


PanelsResult CodeDescription0Success-1General error.-2Invalid mode.-3Required data not found in the Setup.iss file.-4Not enough memory available.-5File does not exist.-6Cannot write to the response file.-7Unable to write to the log file.-8Invalid path to the InstallShield Silent response (.iss) file.-9Not a valid list type (string or number).-10Data type is invalid.-11Unknown error during setup.-12Dialog boxes are out of order.-51Cannot create the specified folder.-52Cannot access the specified file or folder.-53Invalid option selected.Indicator ValueType of export1Excel with Formatting2PDF3Excel with Plain Text (OR) CSV (OR) Plain Text12Export to Flash using MHT as container**13Export to Flash using PDF as container**BeforeAfter

select a12.QUARTER_ID QUARTER_ID,
max(a13.QUARTER_DESC) QUARTER_DESC,
a11.DAY_DATE DAY_DATE,
sum(a11.TOT_DOLLAR_SALES) Revenue
from DAY_CTR_SLS a11
join LU_DAY a12
on (a11.DAY_DATE = a12.DAY_DATE)
join LU_QUARTER a13
on (a12.QUARTER_ID = a13.QUARTER_ID)
where a12.YEAR_ID in (2006)
group by a12.QUARTER_ID,
a11.DAY_DATE

select a12.QUARTER_ID QUARTER_ID,
max(a13.QUARTER_DESC) QUARTER_DESC,
a11.DAY_DATE DAY_DATE,
sum(a11.TOT_DOLLAR_SALES) Revenue
from DAY_CTR_SLS a11
join LU_DAY a12
on (a11.DAY_DATE = a12.DAY_DATE)
join LU_QUARTER a13
on (a12.QUARTER_ID = a13.QUARTER_ID)
where ((a12.YEAR_ID)
in (select r11.YEAR_ID
from LU_QUARTER r11
where r11.YEAR_ID in (2006)))
group by a12.QUARTER_ID,
a11.DAY_DATE


Comment

0 comments

Details

Knowledge Article

Published:

May 9, 2017

Last Updated:

May 9, 2017