'How to make use of materialize in Kusto?

I have a function called consumption which takes 4 parameters and finally summarizes a value by Name. From this function I am trying to materialize some formulas to have as a result a better query performance.

For example:

let firstFormula = materialize (
    consumption("ID", "scale", "node", 100.0)
);

let secondformula = materialize (
    consumption("ID", "scale", "node", 60.0)
);

I am then creating a formula which divides the value coming from the firstformula by the value coming from secondformula.

let thirdFormula =  view (){
union 
    firstformula,
    secondformula
    | summarize 
        value1 = max(case(Name == "ABCD", todouble(Value), 0.0)),
        value2 = max(case(Name == "EFGH", todouble(Value), 0.0))
    | project Value = round(value1 / value2 * 100.0, 2)
};

I tested the formulas first without using the materialize function in order to check the CPU performance. I then tested it using the materialize. I ended up having a better performance from the one not using the materialize. Am I doing something wrong here ? Am I using the materialize function in a wrong way ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source