避免在查询中多次 运行 一个函数

Avoid running a function multiple times in a query

我在同一查询中多次在 Application Insights where I run the parsejson 函数中使用以下查询。

是否可以在第一次调用后重用 parsejson() 函数中的数据?现在我在查询中调用它三次。我想看看只调用一次是否更有效率。

EventLogs
| where Timestamp > ago(1h)  
        and tostring(parsejson(tostring(Data.JsonLog)).LogId) =~ '567890'
|   project Timestamp, 
    fileSize = toint(parsejson(tostring(Data.JsonLog)).fileSize),  
    pageCount = tostring(parsejson(tostring(Data.JsonLog)).pageCount)
| limit 10

你可以使用 extend

EventLogs
| where Timestamp > ago(1h)
| extend JsonLog = parsejson(tostring(Data.JsonLog)
| where tostring(JsonLog.LogId) =~ '567890'
|   project Timestamp, 
    fileSize = toint(JsonLog.fileSize),  
    pageCount = tostring(JsonLog.pageCount)
| limit 10