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

KB13880: Examples of Level 1 and Level 2 SQL Global Optimization VLDB properties in MicroStrategy SQL Generation Engine 9.x and 10.x


Community Admin

• Strategy


The following examples demonstrate how Level 1 and Level 2 SQL Global Optimization settings work in MicroStrategy SQL Generation Engine 9.x and 10.x

The following examples demonstrate how Level 1 and Level 2 SQL Global Optimization settings work in Strategy SQL Generation Engine 9.x and 10.x
 
Using the Strategy Tutorial project, create a report with the ‘Year’ and ‘Region’ attributes, and the ‘Profit’ metric in the grid. Create a report filter with a set qualification on the ‘Revenue’ metric and ‘Category’ output, as shown below:
 

ka04W000000OhlQQAS_0EM440000002FVL.gif

 
The following SQL is generated:
 
First Pass:


create table ZZMQ00 (
   CATEGORY_ID BYTE)
 insert into
ZZMQ00
select   a11. AS CATEGORY_ID
from      a11
group by a11.
having   sum(a11.) > 1000000.0

 
Second Pass:

select   a15. AS YEAR_ID,
         a14. AS REGION_ID,
         max(a16.) AS REGION_NAME,
         sum((a11. - a11.)) AS WJXBFS1
from      a11,
          a12,
               pa13,
          a14,
             a15,
            a16
where    a11. = a12. and
         a12. = pa13. and
         a11. = a14. and
         a11. = a15. and
         a14. = a16.
group by a15.,
         a14.
 drop table ZZMQ00

 
The table created in the first pass is used in the second pass.
 
REMOVING UNUSED PASSES
In order to create a redundant pass scenario, set the Dimensionality (Level) for the ‘Profit’ metric to Report Level and set Filtering on ‘Category’ to ignore, as shown below:
 

ka04W000000OhlQQAS_0EM440000002FVM.gif

 
The SQL generated is:
 
First Pass:


create table ZZMQ00 (
  CATEGORY_ID BYTE)
 insert into ZZMQ00
 select      a11. AS CATEGORY_ID
from         a11
group by    a11.
having      sum(a11.) > 1000000.0

 
Second Pass:

select   a12. AS YEAR_ID,
         a11. AS REGION_ID,
         max(a13.) AS REGION_NAME,
         sum((a11. - a11.)) AS WJXBFS1
from      a11,
          a12,
          a13
where    a11. = a12. and
         a11. = a13.
group by a12.,
         a11.
 drop table ZZMQ00

 
In the above SQL, notice that the first pass is not being used anywhere and is redundant. Select the Level 1 option in the SQL Global Optimization VLDB property to remove unused and duplicate passes, as shown below:
 

ka04W000000OhlQQAS_0EM440000002FVV.png

 
If the report SQL is generated again, notice that the unused pass has been dropped:
 

Explicit
create table ZZEA00 nologging as
select   a11.SUBCAT_ID SUBCAT_ID,
   rank () over( order by (a11.TOT_DOLLAR_SALES - a11.TOT_COST) desc nulls last) WJXBFS1
from   SUBCAT_SLS   a11create table ZZAM00 nologging as
select   a11.SUBCAT_ID SUBCAT_ID,
   rank () over( order by (a11.TOT_DOLLAR_SALES - a11.TOT_COST) desc nulls last) WJXBFS1
from   SUBCAT_SLS   a11 create table ZZAM01 nologging as
select   pa11.SUBCAT_ID SUBCAT_ID,
   pa11.WJXBFS1 WJXBFS1
from   ZZEA00   pa11
 
create table ZZEA02 nologging as
select   pa11.SUBCAT_ID SUBCAT_ID,
   pa11.WJXBFS1 WJXBFS1
from   ZZAM01   pa11  create table ZZMQ03 nologging as
select   pa11.SUBCAT_ID SUBCAT_ID
from   ZZEA02   pa11
where   (pa11.WJXBFS1 <= 5.0)
 
create table ZZEA04 nologging as
select   a11.SUBCAT_ID SUBCAT_ID,
   a11.TOT_DOLLAR_SALES WJXBFS1,
   (a11.TOT_DOLLAR_SALES - a11.TOT_COST) WJXBFS2
from   SUBCAT_SLS   a11,
   ZZMQ03   pa12
where   a11.SUBCAT_ID = pa12.SUBCAT_ID
 
select   pa11.SUBCAT_ID SUBCAT_ID,
   a12.SUBCAT_DESC SUBCAT_DESC,
   pa11.WJXBFS1 WJXBFS1,
   pa11.WJXBFS2 WJXBFS2
from   ZZEA04   pa11, 
   LU_SUBCATEG   a12
where   pa11.SUBCAT_ID = a12.SUBCAT_IDcreate table ZZMQ01 nologging as
select   pa11.SUBCAT_ID SUBCAT_ID
from   ZZAM00   pa11
where   (pa11.WJXBFS1 <= 5.0)
 
select   a11.SUBCAT_ID SUBCAT_ID,
   a13.SUBCAT_DESC SUBCAT_DESC,
   a11.TOT_DOLLAR_SALES WJXBFS1,
   (a11.TOT_DOLLAR_SALES - a11.TOT_COST) WJXBFS2
from   SUBCAT_SLS   a11, 
   ZZMQ01   pa12, 
   LU_SUBCATEG   a13
where   a11.SUBCAT_ID = pa12.SUBCAT_ID and 
   a11.SUBCAT_ID = a13.SUBCAT_ID Function TypeBuilt-inUser-DefinedExampleSELECT   base64(dt_binary)
FROM   wh2.dt_fact_table1;CREATE TEMPORARY FUNCTION c_to_string AS 'org.apache.hadoop.hive.ql.udf.UDFToString';
 
SELECT   c_to_string(dt_binary)
FROM   wh2.dt_fact_table1;FunctionSQL PatternAdd(#0#< + #*#>)  Average(#0#< + #*#>) / (((0 * #0) + 1)#< + ((0 * #*) + 1)#>)  AvgAVG(#0#<#*#>) CountCOUNT(#0#<#*#>) GeoMeanFunctionEXP(AVG(LN(#0))) GreatestFunctionGREATEST(#0#<, #*#>) LeastFunctionLEAST(#0#<, #*#>) MaxMAX(#0#<#*#>) MinMIN(#0#<#*#>) Multiply(#0#< * #*#>)  StdevFunctionSTDDEV(#0#< #*#>) SumSUM(#0#<#*#>) VarFunctionVAR(#0#< #*#>) FunctionSQL PatternConcatFunctionCONCAT(#0, #1) LengthFunctionLENGTH(#0)LowerFunctionLOWER(#0) LTrimFunctionLTRIM(#0) PositionFunctionLOCATE(#1, #0) RTrimFunctionRTRIM(#0) SubStrFunctionSUBSTRING(#0, #1, #2) InitCapFunction(UPPER(SUBSTRING(#0, 1, 1)) || LOWER(SUBSTRING(#0, 2, Length(#0) - 1))) TrimFunctionLTRIM(RTRIM(#0)) RightStrFunctionRIGHT(#0, #1) LeftStrFunctionLEFT(#0, #1) UpperFunctionUPPER(#0) ConcatBlankFunction(#0#< || ' ' || #*#>) FunctionSQL PatternDaysBetweenFunctionDAYS_BETWEEN(#0, #1)YearEndDateFunctionADD_DAYS(ADD_MONTHS (#0, (13 - EXTRACT(MONTH FROM #0))),- EXTRACT(DAY FROM #0))CurrentDateFunctionNOW()DayOfMonthFunctionDAYOFMONTH(#0)DayOfWeekFunction(CASE WHEN WEEKDAY(#0) =6 THEN WEEKDAY(#0)-5 ELSE WEEKDAY(#0)+2 END)DayOfYearFunctionDAYOFYEAR(#0)WeekFunctionTO_CHAR(#0,'WW')MonthFunctionMONTH(#0)QuarterFunctionTO_CHAR (#0, 'Q')YearFunctionYEAR(#0)CurrentDateTimeFunctionNOW()CurrentTimeFunctionNOW()HourFunctionHOUR(#0)MinuteFunctionMINUTE(#0)SecondFunctionROUND(SECOND(#0))MilliSecondFunctionsubstring(cast(extract(second from #0) as char(10)), 4, 3)MonthStartDateFunctionADD_DAYS(#0,1-DAYOFMONTH(#0))YearStartDateFunctionADD_MONTHS (ADD_DAYS (#0, 1 - (EXTRACT(DAY FROM #0))), 1 -(EXTRACT(MONTH FROM #0)))AddMonthsFunctionADD_MONTHS(#0, #1)MonthsBetweenFunction(12 * (EXTRACT(YEAR FROM #1) - EXTRACT(YEAR FROM #0)) + EXTRACT(MONTH FROM #1) - EXTRACT(MONTH FROM #0) - (CASE WHEN EXTRACT(DAY FROM #0) > EXTRACT (DAY FROM #1) THEN 1 ELSE 0 END))AddDaysFunctionADD_DAYS(#0, #1)MonthEndDateFunctionADD_DAYS((ADD_MONTHS(#0, 1)), -DAYOFMONTH((ADD_MONTHS(#0, 1))))DateFunctionTO_DATE(#0,'YYYY-MM-DD')FunctionSQL PatternLagFunctionlag(#0#<, #*#>) over ([#P] [#O]) LeadFunctionlead(#0#<, #*#>) over ([#P] [#O]) OLAPRankFunctionrank() over ([#P] [#O])FunctionSQL PatternRound2FunctionROUND(#0, #1)RankFunction#0#,#<partition by#>#<#, #*#>#|rank () over(#1#2#<, #*#> order by #0)AbsFunctionABS(#0)IntersectFunction#<(#>#1#<#0 intersect #*#>#<)#>Int2FunctionFLOOR(#0)AcosFunctionACOS(#0)AcoshFunctionLN(#0+SQRT(#0-1)*SQRT(#0+1))AsinFunctionASIN(#0)AtanFunctionATAN(#0)Atan2FunctionATAN2(#1, #0)AtanhFunction((LN(1+#0)-LN(1- #0))/2)CeilingFunctionCEILING(#0)CosFunctionCOS(#0)CoshFunctionCOSH(#0)ExpFunctionEXP(#0)FloorFunctionFLOOR(#0)IntFunctionFLOOR(#0)LnFunctionLN(#0)LogFunctionLOG(#1, #0)Log10FunctionLOG(10,#0)PowerFunctionPOWER(#0, #1)QuotientFunction
 (CASE WHEN SIGN(#0/NULLIF(#1, 0)) =1 THEN FLOOR (#0/NULLIF(#1,0)) ELSE CEILING (#0/NULLIF(#1,0)) END)RoundFunctionROUND(#0, 0)SinFunctionSIN(#0)SinhFunctionSINH(#0)SqrtFunctionSQRT(#0)TanFunctionTAN(#0)TanhFunctionTANH(#0)TruncFunctionCAST(#0 AS INTEGER)AsinhFunctionLN(#0+SQRT(POWER(#0,2)+1))ModFunctionMOD(#0, #1)ItemExampleApplication server versionTomcat 7.0, IIS 7.5, etc.Application server operating systemWindows 2008 R2Operating system bit type64-bitStrategy Web version9.4.1 Hotfix 9Machine physical memory8 GBNumber of CPUs and speedDual core @ 2.4 GhzJava version1.8.0 update 60Java max heap size2048 MOther Java parametersVerbose GC loggingAverage user concurrency on peak times100select count(distinct a11.REGION_ID)  WJXBFS1
from LU_REGION a11 select count(distinct a13.REGION_ID)  WJXBFS1
from LU_CALL_CTR a13
where a13.MANAGER_ID in (1)select distinct a11.REGION_ID  REGION_ID,
   a11.REGION_NAME  REGION_NAME0
from LU_REGION a11select distinct a12.REGION_ID  REGION_ID,
   a13.REGION_NAME  REGION_NAME0
from LU_CALL_CTR a12
   join LU_REGION a13
      on  (a12.REGION_ID = a13.REGION_ID)
where a12.MANAGER_ID in (1)2012 NULL Without SettingWith Setting

Explicit
create table ZZEA00 nologging as
select   a11.SUBCAT_ID SUBCAT_ID,
   rank () over( order by (a11.TOT_DOLLAR_SALES - a11.TOT_COST) desc nulls last) WJXBFS1
from   SUBCAT_SLS   a11create table ZZAM00 nologging as
select   a11.SUBCAT_ID SUBCAT_ID,
   rank () over( order by (a11.TOT_DOLLAR_SALES - a11.TOT_COST) desc nulls last) WJXBFS1
from   SUBCAT_SLS   a11 create table ZZAM01 nologging as
select   pa11.SUBCAT_ID SUBCAT_ID,
   pa11.WJXBFS1 WJXBFS1
from   ZZEA00   pa11
 
create table ZZEA02 nologging as
select   pa11.SUBCAT_ID SUBCAT_ID,
   pa11.WJXBFS1 WJXBFS1
from   ZZAM01   pa11  create table ZZMQ03 nologging as
select   pa11.SUBCAT_ID SUBCAT_ID
from   ZZEA02   pa11
where   (pa11.WJXBFS1 <= 5.0)
 
create table ZZEA04 nologging as
select   a11.SUBCAT_ID SUBCAT_ID,
   a11.TOT_DOLLAR_SALES WJXBFS1,
   (a11.TOT_DOLLAR_SALES - a11.TOT_COST) WJXBFS2
from   SUBCAT_SLS   a11,
   ZZMQ03   pa12
where   a11.SUBCAT_ID = pa12.SUBCAT_ID
 
select   pa11.SUBCAT_ID SUBCAT_ID,
   a12.SUBCAT_DESC SUBCAT_DESC,
   pa11.WJXBFS1 WJXBFS1,
   pa11.WJXBFS2 WJXBFS2
from   ZZEA04   pa11, 
   LU_SUBCATEG   a12
where   pa11.SUBCAT_ID = a12.SUBCAT_IDcreate table ZZMQ01 nologging as
select   pa11.SUBCAT_ID SUBCAT_ID
from   ZZAM00   pa11
where   (pa11.WJXBFS1 <= 5.0)
 
select   a11.SUBCAT_ID SUBCAT_ID,
   a13.SUBCAT_DESC SUBCAT_DESC,
   a11.TOT_DOLLAR_SALES WJXBFS1,
   (a11.TOT_DOLLAR_SALES - a11.TOT_COST) WJXBFS2
from   SUBCAT_SLS   a11, 
   ZZMQ01   pa12, 
   LU_SUBCATEG   a13
where   a11.SUBCAT_ID = pa12.SUBCAT_ID and 
   a11.SUBCAT_ID = a13.SUBCAT_ID Function TypeBuilt-inUser-DefinedExampleSELECT   base64(dt_binary)
FROM   wh2.dt_fact_table1;CREATE TEMPORARY FUNCTION c_to_string AS 'org.apache.hadoop.hive.ql.udf.UDFToString';
 
SELECT   c_to_string(dt_binary)
FROM   wh2.dt_fact_table1;FunctionSQL PatternAdd(#0#< + #*#>)  Average(#0#< + #*#>) / (((0 * #0) + 1)#< + ((0 * #*) + 1)#>)  AvgAVG(#0#<#*#>) CountCOUNT(#0#<#*#>) GeoMeanFunctionEXP(AVG(LN(#0))) GreatestFunctionGREATEST(#0#<, #*#>) LeastFunctionLEAST(#0#<, #*#>) MaxMAX(#0#<#*#>) MinMIN(#0#<#*#>) Multiply(#0#< * #*#>)  StdevFunctionSTDDEV(#0#< #*#>) SumSUM(#0#<#*#>) VarFunctionVAR(#0#< #*#>) FunctionSQL PatternConcatFunctionCONCAT(#0, #1) LengthFunctionLENGTH(#0)LowerFunctionLOWER(#0) LTrimFunctionLTRIM(#0) PositionFunctionLOCATE(#1, #0) RTrimFunctionRTRIM(#0) SubStrFunctionSUBSTRING(#0, #1, #2) InitCapFunction(UPPER(SUBSTRING(#0, 1, 1)) || LOWER(SUBSTRING(#0, 2, Length(#0) - 1))) TrimFunctionLTRIM(RTRIM(#0)) RightStrFunctionRIGHT(#0, #1) LeftStrFunctionLEFT(#0, #1) UpperFunctionUPPER(#0) ConcatBlankFunction(#0#< || ' ' || #*#>) FunctionSQL PatternDaysBetweenFunctionDAYS_BETWEEN(#0, #1)YearEndDateFunctionADD_DAYS(ADD_MONTHS (#0, (13 - EXTRACT(MONTH FROM #0))),- EXTRACT(DAY FROM #0))CurrentDateFunctionNOW()DayOfMonthFunctionDAYOFMONTH(#0)DayOfWeekFunction(CASE WHEN WEEKDAY(#0) =6 THEN WEEKDAY(#0)-5 ELSE WEEKDAY(#0)+2 END)DayOfYearFunctionDAYOFYEAR(#0)WeekFunctionTO_CHAR(#0,'WW')MonthFunctionMONTH(#0)QuarterFunctionTO_CHAR (#0, 'Q')YearFunctionYEAR(#0)CurrentDateTimeFunctionNOW()CurrentTimeFunctionNOW()HourFunctionHOUR(#0)MinuteFunctionMINUTE(#0)SecondFunctionROUND(SECOND(#0))MilliSecondFunctionsubstring(cast(extract(second from #0) as char(10)), 4, 3)MonthStartDateFunctionADD_DAYS(#0,1-DAYOFMONTH(#0))YearStartDateFunctionADD_MONTHS (ADD_DAYS (#0, 1 - (EXTRACT(DAY FROM #0))), 1 -(EXTRACT(MONTH FROM #0)))AddMonthsFunctionADD_MONTHS(#0, #1)MonthsBetweenFunction(12 * (EXTRACT(YEAR FROM #1) - EXTRACT(YEAR FROM #0)) + EXTRACT(MONTH FROM #1) - EXTRACT(MONTH FROM #0) - (CASE WHEN EXTRACT(DAY FROM #0) > EXTRACT (DAY FROM #1) THEN 1 ELSE 0 END))AddDaysFunctionADD_DAYS(#0, #1)MonthEndDateFunctionADD_DAYS((ADD_MONTHS(#0, 1)), -DAYOFMONTH((ADD_MONTHS(#0, 1))))DateFunctionTO_DATE(#0,'YYYY-MM-DD')FunctionSQL PatternLagFunctionlag(#0#<, #*#>) over ([#P] [#O]) LeadFunctionlead(#0#<, #*#>) over ([#P] [#O]) OLAPRankFunctionrank() over ([#P] [#O])FunctionSQL PatternRound2FunctionROUND(#0, #1)RankFunction#0#,#<partition by#>#<#, #*#>#|rank () over(#1#2#<, #*#> order by #0)AbsFunctionABS(#0)IntersectFunction#<(#>#1#<#0 intersect #*#>#<)#>Int2FunctionFLOOR(#0)AcosFunctionACOS(#0)AcoshFunctionLN(#0+SQRT(#0-1)*SQRT(#0+1))AsinFunctionASIN(#0)AtanFunctionATAN(#0)Atan2FunctionATAN2(#1, #0)AtanhFunction((LN(1+#0)-LN(1- #0))/2)CeilingFunctionCEILING(#0)CosFunctionCOS(#0)CoshFunctionCOSH(#0)ExpFunctionEXP(#0)FloorFunctionFLOOR(#0)IntFunctionFLOOR(#0)LnFunctionLN(#0)LogFunctionLOG(#1, #0)Log10FunctionLOG(10,#0)PowerFunctionPOWER(#0, #1)QuotientFunction
 (CASE WHEN SIGN(#0/NULLIF(#1, 0)) =1 THEN FLOOR (#0/NULLIF(#1,0)) ELSE CEILING (#0/NULLIF(#1,0)) END)RoundFunctionROUND(#0, 0)SinFunctionSIN(#0)SinhFunctionSINH(#0)SqrtFunctionSQRT(#0)TanFunctionTAN(#0)TanhFunctionTANH(#0)TruncFunctionCAST(#0 AS INTEGER)AsinhFunctionLN(#0+SQRT(POWER(#0,2)+1))ModFunctionMOD(#0, #1)ItemExampleApplication server versionTomcat 7.0, IIS 7.5, etc.Application server operating systemWindows 2008 R2Operating system bit type64-bitStrategy Web version9.4.1 Hotfix 9Machine physical memory8 GBNumber of CPUs and speedDual core @ 2.4 GhzJava version1.8.0 update 60Java max heap size2048 MOther Java parametersVerbose GC loggingAverage user concurrency on peak times100select count(distinct a11.REGION_ID)  WJXBFS1
from LU_REGION a11 select count(distinct a13.REGION_ID)  WJXBFS1
from LU_CALL_CTR a13
where a13.MANAGER_ID in (1)select distinct a11.REGION_ID  REGION_ID,
   a11.REGION_NAME  REGION_NAME0
from LU_REGION a11select distinct a12.REGION_ID  REGION_ID,
   a13.REGION_NAME  REGION_NAME0
from LU_CALL_CTR a12
   join LU_REGION a13
      on  (a12.REGION_ID = a13.REGION_ID)
where a12.MANAGER_ID in (1)2012 NULL Without SettingWith Setting

 
First Pass:
 
create table ZZMQ00 (
 
   CATEGORY_ID BYTE)
 
insert into ZZMQ00
 
select      a11. AS CATEGORY_ID
from         a11
group by    a11.
having      sum(a11.) > 1000000.0
 
Second Pass:
select   a12. AS YEAR_ID,
         a11. AS REGION_ID,
         max(a13.) AS REGION_NAME,
         sum((a11. - a11.)) AS WJXBFS1
from      a11,
          a12,
          a13
where    a11. = a12. and
         a11. = a13.
group by a12.,
         a11.


Report: A2

Cache Used: No

 

 

         a11. AS REGION_ID,

         max(a13.) AS REGION_NAME,

         sum((a11. - a11.)) AS WJXBFS1

from      a11,

          a12,

          a13

where    a11. = a12. and

         a11. = a13.

group by a12.,

         a11.
Without SettingWith Setting

REMOVING DUPLICATE PASSES
Create a report that will have duplicate passes, such as the report shown below:
 

ka04W000000OhlQQAS_0EM440000002FVi.gif

 
 
'A3 Profit F1' is the ‘Profit’ metric with Condition F1. F1 is a ‘Set of’ filter on the ‘Revenue’ metric, and the filter has an output level on the attribute ‘Category’, with the operator Greater than 1000000, as shown below:
 

ka04W000000OhlQQAS_0EM440000002FVK.gif

 
 
Create another filter F2 with the same parameters as F1, but do not copy or use the same filter, as the optimization engine will otherwise not generate a duplicate pass. Generate report SQL (see the table below under ‘Without Setting’). Now set the Global Optimization VLDB Property to Remove Duplicate and Unused Passes and execute the report SQL:
 

         a11.
Without SettingWith Setting

         a11.
Without SettingWith Setting

 
First Pass

create table ZZMQ00 (

         CATEGORY_ID BYTE)

 

 

select   a11. AS CATEGORY_ID

from      a11

group by a11.

having   sum(a11.) > 1000000.0

 
Second Pass

 
create table ZZMQ01 (

 

         CATEGORY_ID BYTE)

 

insert into ZZMQ01

select   a11. AS CATEGORY_ID

from      a11

group by a11.

having   sum(a11.) > 1000000.0

 

 
Third Pass

 
create table ZZMD02 (

 

         YEAR_ID         SHORT,

         WJXBFS1         DOUBLE)

 
insert into ZZMD02

 

select   a11. AS YEAR_ID,

         sum((a11. - a11.)) AS WJXBFS1

from      a11,

          pa12

where    a11. = pa12.

group by a11.

 
Fourth Pass

create table ZZMD03 (

         YEAR_ID         SHORT,

         WJXBFS1         DOUBLE)

 

 

select   a11. AS YEAR_ID,

         sum((a11. - a11.)) AS WJXBFS1

from      a11,

          pa12

where    a11. = pa12.

group by a11.
Fifth Pass

select   pa11. AS YEAR_ID,

         pa11. AS WJXBFS1,

         pa12. AS WJXBFS2

from      pa11,

          pa12

where    pa11. = pa12.

drop table ZZMQ00

drop table ZZMQ01

drop table ZZMD02

drop table ZZMD03

Report: A3 with setting

Cache Used: No

 

 

         CATEGORY_ID BYTE)

 

 

select   a11. AS CATEGORY_ID

from      a11

group by a11.

having   sum(a11.) > 1000000.0

 

 

         YEAR_ID         SHORT,

         WJXBFS1         DOUBLE)

 

 

select   a11. AS YEAR_ID,

         sum((a11. - a11.)) AS WJXBFS1

from      a11,

          pa12

where    a11. = pa12.

group by a11.

select   pa12. AS YEAR_ID,

         pa12. AS WJXBFS1

from      pa12

 

 

 
Without SettingWith Setting

Notice that two out of the five SQL passes have been dropped.
 
MERGING PASSES WITH DIFFERENT SELECT
Select the Level e option in the SQL Global Optimization VLDB property to merge passes with different select, as shown below:

ka04W000000OhlQQAS_0EM440000002FVo.png

Remove Report Level conditionality from the ‘Revenue’ metric and set Grouping and Filtering to Standard by Region attribute. This will be the 'A4 Revenue’ metric and it will be the total Revenue for each Region, as shown below:
 

ka04W000000OhlQQAS_0EM440000002FVj.gif

 
 
Create a new metric 'A4 Call Center’ count metric with the following formula:
 
Count() {~}
Highlight the formula in the metric and right-click and select ‘Count parameters’ as shown below:
 

ka04W000000OhlQQAS_0EM440000002FVT.gif

 
 
In the Count Parameters console, set the FactID to Revenue, as shown below:
 

ka04W000000OhlQQAS_0EM440000002FVJ.gif

 
 
The ‘A4 Call Center’ count metric will be the number of Call Centers for each Region.
 
Create a compound metric ‘A4 Average Revenue’ that will give the average revenue using the following formula:
 
(A4 Revenue Metric)/(A4 Call center Count Metric)
Create a report with ‘Region’, ’ A4 Revenue Metric’, and ‘A4 Average Revenue’ in the grid, as shown below:
 

ka04W000000OhlQQAS_0EM440000002FVk.gif

 
 
Execute the report and capture the SQL (see the table below under ‘Without Setting’). Now set the 'Merge Passes with Different Select' VLDB Property and execute SQL:
 

 
Without SettingWith Setting

 
Without SettingWith Setting

Report: A4 Without setting

Cache Used: No

 
First Pass:

create table ZZMD00 (

         REGION_ID       BYTE,

         WJXBFS1         DOUBLE)

 

 

select   a12. AS REGION_ID,

         
sum(a11.) AS WJXBFS1

 

from       a11,

            a12

where    a11. = a12.

group by a12.

 
Second Pass:

create table ZZMD01 (

         REGION_ID       BYTE,

         WJXBFS1         LONG)

 

 

select   a12. AS REGION_ID,

         
count(a11.) AS WJXBFS1

 

from       a11,

            a12

where    a11. = a12.

group by a12.
Third Pass:

select   pa11. AS REGION_ID,

         a13. AS REGION_NAME,

         pa11. AS WJXBFS1,

         IIF(ISNULL((pa11. / IIF(pa12. = 0, NULL, pa12.))), 0, (pa11. / IIF(pa12. = 0, NULL, pa12.))) AS WJXBFS2

from             pa11,

                 pa12,

              a13

where    pa11. = pa12. and

         pa11. = a13.

 

 

 

Report: A4 With setting

Cache Used: No

 
First Pass (retrieves both metrics in the same pass):

create table ZZMD00 (

         REGION_ID       BYTE,

         WJXBFS1         DOUBLE,

         WJXBFS2         LONG)

 

 

select   a12. AS REGION_ID,

         
sum(a11.) AS WJXBFS1,

 

         count(a11.) AS WJXBFS2

from       a11,

            a12

where    a11. = a12.

group by a12.
Second Pass:

select   pa12. AS REGION_ID,

         a13. AS REGION_NAME,

         pa12. AS WJXBFS1,

         IIF(ISNULL((pa12. / IIF(pa12. = 0, NULL, pa12.))), 0, (pa12. / IIF(pa12. = 0, NULL, pa12.))) AS WJXBFS2

from             pa12,

              a13

where    pa12. = a13.

 

 


Comment

0 comments

Details

Knowledge Article

Published:

April 14, 2017

Last Updated:

April 14, 2017