如何在 Kusto 中使用 Materialize?
我有一个名为“consumation”的函数,它接受 4 个参数,最后按名称汇总一个值。从这个函数中,我试图具体化一些公式,以获得更好的查询性能。
例如:
let firstFormula = materialize (
consumption("ID", "scale", "node", 100.0)
);
let secondformula = materialize (
consumption("ID", "scale", "node", 60.0)
);
然后我创建一个公式,它将来自第一个公式的值除以来自第二个公式的值。
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)
};
我首先在不使用 Materialize 函数的情况下测试了公式,以检查 CPU 性能。然后我使用 Materialize 对其进行了测试。我最终获得了比不使用实体化更好的性能。我在这里做错了什么吗?我是否以错误的方式使用了实体化函数?
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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Materialize() 函数对于缓存将在后续查询语句中使用的查询结果非常有用,例如,如果您有一个组织的汇总,然后有一列将其显示为总数的百分比,在这种情况下具体化结果聚合然后计算总数,将显着减少(可能几乎一半)处理时间,例如:
在您的情况下,您似乎正在具体化处理每一行的结果,但从未多次使用具体化数据然后证明缓存成本的合理性这导致了更高的查询成本。
The materialize() function is useful to cache query results that will be used in subsequent query statements, for example, if you have a summarization by an organization and then a column that displays it as percentage of the total, in such case materializing the results of the aggregation and then calculating the total, will reduce significantly (probably by almost a half) the processing time, for example:
In Your case, it seems that you are materializing the results of processing each row but never used the materialized data multiple times afterward to justify the caching cost and this resulted in a higher query cost.