martes, 6 de agosto de 2013

Optimisation of Essbase Calculation Scripts

Essbase 11.1.2 - Optimisation of Essbase Calculation Scripts Using NOT in IF statements

In Essbase calculation scripts, when an IF statement is performed, it will perform the first element of the IF statement first, check if the combination being calculated meets that criteria and calculate it if it does or pass to the next element, i.e the next ELSEIF. This will continue through all the ELSEIF statements and then the ELSE (if present) if the combination does not meet any of the criteria of the IF or ELSEIF.
It is possible to optimise an IF statement by first analysing which condition will be met by the majority of your data and then to try and place this IF statement as near to the top of your IF statement as possible ... if possible, of course.
In Sample.Basic (where Accounts and Time are dense), in order to illustrate this, I added a child of “Ratios” of “SalesYTD”. I then wrote the following Essbase Calculation script as an example:
SET UPDATECALC OFF;
"SalesYTD"(
IF(@ismbr("Jan"))
"SalesYTD" = "Sales";
Else
"SalesYTD"="Sales" + @prior("SalesYTD");
Endif)
In this case, 11/12th of the data meets the criteria of the ELSE condition. Only 1/12th of the data meets the criteria of the IF. Because of the @prior function in the else condition, January would have to be calculated before all other months. I will come back to this later.
I cleared and loaded the calcdat.txt data file and ran this calculation:
Total Calc Elapsed Time for [IF.csc] : [0.203] seconds
Notice that the “SalesYTD” member is calculated in Cell mode. This means that January, because it appears before other months in the outline, will be calculated first, regardless of the IF order:
Formula for member [SalesYTD] will be executed in [CELL] mode
I then changed the calculation script, switching the order of the statements and adding a NOT operator to the first condition:
SET UPDATECALC OFF;
"SalesYTD"(
IF(NOT(@ismbr("Jan")))
"SalesYTD" = "Sales" + @prior("SalesYTD");
Else
"SalesYTD"="Sales";
Endif)
I cleared, reloaded the calcdat.txt datafile, and re-ran the calculation.
The calculation, in this case, takes less than a quarter of the time in the first script because 11/12th of the data meet the criteria of the first statement in the IF block:
Total Calc Elapsed Time for [NOTIF.csc] : [0.047] seconds
In this example, it is imperative that the formula is calculated in outline order to get the correct results i.e. February must be calculated after January, March after February etc.You can use the @calcmode(Cell); command to force this to happen if it does not happen automatically. 
When tuning the heap size for Essbase, there are two JVM_OPTIONS settings available for Essbase - one for the Essbase agent and one for the Essbase applications that are using custom-defined functions (CDFs), custom-defined macros (CDMs), data mining, triggers or external authentication.


  • ESS_JVM_OPTION setting is used for the application and mainly for CDFs, CDMs, data mining, triggers, external authentication
  • ESS_CSS_JVM_OPTION setting is used to set the heap size for the Essbase agent

No hay comentarios:

Publicar un comentario