Share via

materialize can reduce CPU time?

Anonymous
2023-11-06T02:23:51.0133333+00:00

From official document https://kusto.azurewebsites.net/docs/kusto/query/materializefunction.html, materialize can improve the performance when use operator "union":

  • Use materialize with join or union when their operands have mutual subqueries that can be executed once. For example, join/union fork legs. See example of using join operator.

let View_SelectArgMax = (

let View_SelectArgMin = (

let View_Grid = materialize(     union View_SelectArgMax, View_SelectArgMin

Do we need to add materialize to variable "View_SelectArgMax " and "View_SelectArgMin"? I tested on my local, it seems if we add materialize then the cpu performance will improve. Could you help to explain why? For above code, do we need to add materialize as below? let View_SelectArgMax = materialize(

let View_SelectArgMin = materialize(

let View_Grid = materialize(     union View_SelectArgMax, View_SelectArgMin

Azure Data Explorer
Azure Data Explorer

An Azure data analytics service for real-time analysis on large volumes of data streaming from sources including applications, websites, and internet of things devices.


Answer accepted by question author

Bhargava-MSFT 31,361 Reputation points Microsoft Employee Moderator
2023-11-07T01:29:25.8266667+00:00

Hello Jianbo Yao (Centific Technologies Inc),

Welcome to the Microsoft Q&A forum.

materialize() caches a result set.  It is useful when you reuse that result set multiple times during a query.

so it doesn’t need to be computed again when it’s used multiple times in the main query.

In your case, if View_SelectArgMax and View_SelectArgMin are used multiple times in your queries, then adding materialize to these variables can indeed improve performance.

This is because the results of these subqueries are computed once and then stored, reducing the amount of computation needed when they’re used again.

However, if these variables are only used once in your queries, then adding materialize might not lead to a noticeable improvement in performance.

I hope this helps. Please let me know if you have any further questions.

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.