批处理Batches

一个查询可以包含多个表格表达式语句,只要以分号 (;) 字符分隔它们即可。A query can include multiple tabular expression statements, as long as they're delimited by a semicolon (;) character. 这样,该查询会返回多个表格结果。The query then returns multiple tabular results. 结果由表格表达式语句产生,并根据查询文本中语句的顺序进行排序。Results are produced by the tabular expression statements and ordered according to the order of the statements in the query text.

例如,以下查询产生两个表格结果。For example, the following query produces two tabular results. 然后,用户代理工具可以显示这些结果以及与每个结果相关联的适当名称(分别为 Count of events in FloridaCount of events in Guam)。User agent tools can then display those results with the appropriate name associated with each (Count of events in Florida and Count of events in Guam, respectively).

StormEvents | where State == "FLORIDA" | count | as ['Count of events in Florida'];
StormEvents | where State == "GUAM" | count | as ['Count of events in Guam']

对于多个子查询共享一个通用计算的场景(例如仪表板),批处理很有用。Batch is useful for scenarios where a common calculation is shared by multiple subqueries, such as for dashboards. 如果通用计算很复杂,请使用 materialize() 函数,并构造查询以使其仅执行一次:If the common calculation is complex, use the materialize() function and construct the query so that it will be executed only once:

let m = materialize(StormEvents | summarize n=count() by State);
m | where n > 2000;
m | where n < 10

说明:Notes: