Thank you for sharing your feedback. We have looked into the possible alternatives, and here are some steps that may help address the issue:
You are right about how make_list() works—it doesn’t keep the order unless you explicitly sort the data first. The catch is that adding a sort step before summarizing can slow things down, which explains the performance hit you noticed.
Here’s why that happens and what you can try instead:
Why does order by slow things down?
- By default, summarize in Kusto works on unordered data.
- When you add order by Timestamp asc, it forces a full sort across all rows before aggregation, which is costly for large datasets (think hundreds of thousands of rows).
- The union method is faster because it skips the global sort and handles each metric separately.
Ways to improve performance:
- Use arg_min / arg_max for first row only
- Great for single-row retrieval per metric, but not for N rows.
- Chunked approach with take after filtering
- If you can tolerate approximate results:
KQL
Metrics
| where MetricId in (1001, 1011, 1021)
| where Timestamp >= datetime(2024-06-01)
| partition by MetricId
| take N
- Limitation: Doesn’t guarantee strict ordering by timestamp.
- mv-expand + top inside summarize
- Instead of global sort, sort within each group:
KQL
Metrics
| where MetricId in (1001, 1011, 1021)
| where Timestamp >= datetime(2024-06-01)
| summarize readings = make_list(pack('t', Timestamp, 'v', Value)) by MetricId
| mv-expand readings
| order by MetricId, readings.t asc
- This reduces the cost of sorting across all rows.
- Union-based approach for strict ordering
- If metrics list is small and static:
KQL
union (
Metrics | where MetricId == 1001 | where Timestamp >= datetime(2024-06-01) | top N by Timestamp asc,
Metrics | where MetricId == 1011 | where Timestamp >= datetime(2024-06-01) | top N by Timestamp asc,
Metrics | where MetricId == 1021 | where Timestamp >= datetime(2024-06-01) | top N by Timestamp asc
)
- This avoids global sorts and is often fastest for small metric sets.
There’s no built-in way for make_list() to keep the order unless you sort the data first. If maintaining order is important, using a union or a partitioned approach is usually the most practical solution.