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

KB442136: In-Memory query optimization for better performance by removing DISTINCT TUPLE clause and join the table directly


Community Admin

• Strategy


This Knowledge Base article describes In-Memory query optimization for better performance by removing DISTINCT TUPLE clause and join the table directly

Starting with the release of Strategy ONE (March 2024), dossiers are also known as dashboards.
SYMPTOM
In-Memory query is optimized for better performance by removing DISTINCT TUPLE clause and join the table directly. This is only a performance optimization and does not have any impact on the resulting data as it remains same.
STEPS TO REPRODUCE
1. This example uses Strategy Tutorial project schema and an In-Memory Intelligent Cube which contains at least following tables when published:
Tables Accessed:
Table10    [L_CATEGORY]:    Category,         LOOKUP_TABLE    
Table93    [REL_SUBCATEGORY_ITEM]:    Subcategory, Item,         RELATIONSHIP_TABLE,    ONE_TO_MANY
Table106    [REL_CATEGORY_SUBCATEGORY]:    Category, Subcategory,         RELATIONSHIP_TABLE,    ONE_TO_MANY
Table118    [F_INVENTORY_CURR_FORTH]:    Item,     Unit Cost, On Order Qty, Projected Demand Qty,     FACT_TABLE    
Table129    [F_ORDER_DETAIL]:    Promotion, Employee, Item, Day, Customer, Phone Usage, Order,     Unit Cost, Unit Price, Gross Revenue, Revenue, Units Sold, Profit, Cost, DiscountFact, Item Count,     FACT_TABLE    
2. Create a dossier using the Intelligent Cube and create following 4 "Aggregate From Base" metrics as mentioned below:
M1 = Sum<UseLookupForAttributes=True>([On Order Qty]){~+, Promotion%}

ka0PW0000001JSoYAM_0EM44000000J2py.png

M2 = Sum<UseLookupForAttributes=True>(Revenue){Subcategory+}

ka0PW0000001JSoYAM_0EM44000000J2q3.png

M3 = Sum<UseLookupForAttributes=True>(M1){~+}

ka0PW0000001JSoYAM_0EM44000000J2q8.png

M4 = Avg<UseLookupForAttributes=True>(M2){~+}

ka0PW0000001JSoYAM_0EM44000000J2qD.png

Mark all the above metrics as "Aggregate From Base" using "Metric Options" option in the Metric Editor dialog.

ka0PW0000001JSoYAM_0EM44000000J2qI.png

3. Put Category attribute on visualization and M3, M4 metrics. Also define filters on Item and Promotion as specified below (the filter elements could be different on the underlying data source).

ka0PW0000001JSoYAM_0EM44000000J2qS.png

Query Details of the above visualization shows:


*********   Visualization Summary Start  **********
Time Spent: 0.008 sec(s)
Query Execution Start Time: 1/23/2019 5:33:15 PM
Query Execution End Time: 1/23/2019 5:33:15 PM

Note: The total 'Time Spent' above may be greater than the summation of the individual step execution times below.
There are preparation tasks for each step that are not individually measured.
*********   Visualization Summary End    **********

************   Individual Step Start   ************
Number of Rows Returned: 2
Time Spent: 0.007 sec(s)
Query Execution Start Time: 1/23/2019 5:33:15 PM
Query Execution End Time: 1/23/2019 5:33:15 PM

Tables Accessed:
Table10    [L_CATEGORY]:    Category,         LOOKUP_TABLE    
Table93    [REL_SUBCATEGORY_ITEM]:    Subcategory, Item,         RELATIONSHIP_TABLE,    ONE_TO_MANY
Table106    [REL_CATEGORY_SUBCATEGORY]:    Category, Subcategory,         RELATIONSHIP_TABLE,    ONE_TO_MANY
Table118    [F_INVENTORY_CURR_FORTH]:    Item,     Unit Cost, On Order Qty, Projected Demand Qty,     FACT_TABLE    
Table129    [F_ORDER_DETAIL]:    Promotion, Employee, Item, Day, Customer, Phone Usage, Order,     Unit Cost, Unit Price, Gross Revenue, Revenue, Units Sold, Profit, Cost, DiscountFact, Item Count,     FACT_TABLE    

select    [Category]@[CATEGORY_ID],
    [Promotion]@[PROMOTION_ID],
    sum([[F_INVENTORY_CURR_FORTH].On Order Qty])@{[Category],[Promotion]} as [M1]
from    SuperApp
with Table Join Tree:     [F_INVENTORY_CURR_FORTH]<[Item]@[ITEM_ID] in (2, 151)>
     Join [REL_SUBCATEGORY_ITEM] with output level Tuple([Item]@[ITEM_ID], [Subcategory]@[SUBCAT_ID])
     Join [REL_CATEGORY_SUBCATEGORY] with output level Tuple([Category]@[CATEGORY_ID], [Item]@[ITEM_ID])
     Join (Set of distinct Tuple([Item]@[ITEM_ID], [Promotion]@[PROMOTION_ID]) where Tuple([Item]@[ITEM_ID], [Promotion]@[PROMOTION_ID]) in [F_ORDER_DETAIL]) with output level Tuple([Category]@[CATEGORY_ID], [Item]@[ITEM_ID], [Promotion]@[PROMOTION_ID])
Save As TempTable139    

select    [Category]@[CATEGORY_ID],
    sum([TempTable139.M1])@{[Category]} as [M3]
from    SuperApp
with Table Join Tree:     TempTable139<[Promotion]@[PROMOTION_ID] in (0, 2)>
Save As TempTable140    

select    [Subcategory]@[SUBCAT_ID],
    sum([[F_ORDER_DETAIL].Revenue])@{[Subcategory]} as [M2]
from    SuperApp
with Table Join Tree:     [F_ORDER_DETAIL]<([Promotion]@[PROMOTION_ID] in (0, 2)
 and [Item]@[ITEM_ID] in (2, 151))>
     Join [REL_SUBCATEGORY_ITEM] with output level Tuple([Day]@[DAY_DATE], [Employee]@[EMP_ID], [Item]@[ITEM_ID], [Order]@[ORDER_ID], [Phone Usage]@[CUSTOMER_ID], [Subcategory]@[SUBCAT_ID])
Save As TempTable141    

select    [Category]@[CATEGORY_ID],
    avg([TempTable141.M2])@{[Category]} as [M4]
from    SuperApp
with Table Join Tree:     TempTable141
     Join [REL_CATEGORY_SUBCATEGORY] with output level Tuple([Category]@[CATEGORY_ID], [Subcategory]@[SUBCAT_ID])
Save As TempTable142    

select    [Category]@[CATEGORY_ID],
    [Category]@[CATEGORY_DESC],
    [TempTable140.M3] as [M3],
    [TempTable142.M4] as [M4]
from    SuperApp
with Table Join Tree:     TempTable140
     Join TempTable142 with output level Tuple([Category]@[CATEGORY_ID])
     Join ([REL_CATEGORY_SUBCATEGORY]
     Join (Set of distinct Tuple([Subcategory]@[SUBCAT_ID]) where Tuple([Subcategory]@[SUBCAT_ID]) in [REL_SUBCATEGORY_ITEM]<[Item]@[ITEM_ID] in (2, 151)> with output level Tuple([Category]@[CATEGORY_ID])) with output level Tuple([Category]@[CATEGORY_ID])
************   Individual Step End     ************

The set of distinct Tuple (in red above) is not needed and the filter can be directly applied to REL_SUBCATEGORY_ITEM table improving performance of the query.
CAUSE
This is a known limitation in Strategy 10.10 or below..
ACTION
This issue has been addressed in Strategy 10.11. Upgrade to this version or above to take advantage of this fix.
Query Details now shows the Distinct Tuple is now removed from the join tree, improving the query performance:

*********   Visualization Summary Start  **********
Time Spent: 0.008 sec(s)
Query Execution Start Time: 1/23/2019 5:33:15 PM
Query Execution End Time: 1/23/2019 5:33:15 PM

Note: The total 'Time Spent' above may be greater than the summation of the individual step execution times below.
There are preparation tasks for each step that are not individually measured.
*********   Visualization Summary End    **********

************   Individual Step Start   ************
Number of Rows Returned: 2
Time Spent: 0.007 sec(s)
Query Execution Start Time: 1/23/2019 5:33:15 PM
Query Execution End Time: 1/23/2019 5:33:15 PM

Tables Accessed:
Table10    [L_CATEGORY]:    Category,         LOOKUP_TABLE    
Table93    [REL_SUBCATEGORY_ITEM]:    Subcategory, Item,         RELATIONSHIP_TABLE,    ONE_TO_MANY
Table106    [REL_CATEGORY_SUBCATEGORY]:    Category, Subcategory,         RELATIONSHIP_TABLE,    ONE_TO_MANY
Table118    [F_INVENTORY_CURR_FORTH]:    Item,     Unit Cost, On Order Qty, Projected Demand Qty,     FACT_TABLE    
Table129    [F_ORDER_DETAIL]:    Promotion, Employee, Item, Day, Customer, Phone Usage, Order,     Unit Cost, Unit Price, Gross Revenue, Revenue, Units Sold, Profit, Cost, DiscountFact, Item Count,     FACT_TABLE    

select    [Category]@[CATEGORY_ID],
    [Promotion]@[PROMOTION_ID],
    sum([[F_INVENTORY_CURR_FORTH].On Order Qty])@{[Category],[Promotion]} as [M1]
from    SuperApp
with Table Join Tree:     [F_INVENTORY_CURR_FORTH]<[Item]@[ITEM_ID] in (2, 151)>
     Join [REL_SUBCATEGORY_ITEM] with output level Tuple([Item]@[ITEM_ID], [Subcategory]@[SUBCAT_ID])
     Join [REL_CATEGORY_SUBCATEGORY] with output level Tuple([Category]@[CATEGORY_ID], [Item]@[ITEM_ID])
     Join (Set of distinct Tuple([Item]@[ITEM_ID], [Promotion]@[PROMOTION_ID]) where Tuple([Item]@[ITEM_ID], [Promotion]@[PROMOTION_ID]) in [F_ORDER_DETAIL]) with output level Tuple([Category]@[CATEGORY_ID], [Item]@[ITEM_ID], [Promotion]@[PROMOTION_ID])
Save As TempTable139    

select    [Category]@[CATEGORY_ID],
    sum([TempTable139.M1])@{[Category]} as [M3]
from    SuperApp
with Table Join Tree:     TempTable139<[Promotion]@[PROMOTION_ID] in (0, 2)>
Save As TempTable140    

select    [Subcategory]@[SUBCAT_ID],
    sum([[F_ORDER_DETAIL].Revenue])@{[Subcategory]} as [M2]
from    SuperApp
with Table Join Tree:     [F_ORDER_DETAIL]<([Promotion]@[PROMOTION_ID] in (0, 2)
 and [Item]@[ITEM_ID] in (2, 151))>
     Join [REL_SUBCATEGORY_ITEM] with output level Tuple([Day]@[DAY_DATE], [Employee]@[EMP_ID], [Item]@[ITEM_ID], [Order]@[ORDER_ID], [Phone Usage]@[CUSTOMER_ID], [Subcategory]@[SUBCAT_ID])
Save As TempTable141    

select    [Category]@[CATEGORY_ID],
    avg([TempTable141.M2])@{[Category]} as [M4]
from    SuperApp
with Table Join Tree:     TempTable141
     Join [REL_CATEGORY_SUBCATEGORY] with output level Tuple([Category]@[CATEGORY_ID], [Subcategory]@[SUBCAT_ID])
Save As TempTable142    

select    [Category]@[CATEGORY_ID],
    [Category]@[CATEGORY_DESC],
    [TempTable140.M3] as [M3],
    [TempTable142.M4] as [M4]
from    SuperApp
with Table Join Tree:     TempTable140
     Join TempTable142 with output level Tuple([Category]@[CATEGORY_ID])
     Join ([REL_CATEGORY_SUBCATEGORY]
     Join [REL_SUBCATEGORY_ITEM]<[Item]@[ITEM_ID] in (2, 151)> with output level Tuple([Category]@[CATEGORY_ID])) with output level Tuple([Category]@[CATEGORY_ID])
************   Individual Step End     ************

The Strategy Internal Reference Number for the issue discussed in this technical note is KB442136 and DE89732.


Comment

0 comments

Details

Knowledge Article

Published:

October 17, 2018

Last Updated:

March 21, 2024