Skip to main content

console_cluster_utilization_overview_sql

Function console_cluster_utilization_overview_sql 

Source
fn console_cluster_utilization_overview_sql(
    bin: &str,
    retention: &str,
    group_size: u32,
) -> String
Expand description

Builds the SQL body shared by the mz_console_cluster_utilization_overview* views, which power the Console’s cluster utilization graphs.

There is one view per (bucket width, retention window) pair so the Console can read a pre-materialized, indexed rollup for each time range it offers instead of recomputing this (expensive) query on every page load. The bodies must be kept in sync with the equivalent ad-hoc query in the Console (buildReplicaUtilizationHistoryQuery in console/src/api/materialize/cluster/replicaUtilizationHistory.ts).

  • bin: the date_bin bucket width, e.g. 1 MINUTE.
  • retention: how much history the view retains, e.g. 3 HOURS, enforced with a temporal mz_now() filter so the maintained arrangement stays bounded.
  • group_size: the expected number of metric samples per (replica, bucket), used for the DISTINCT ON INPUT GROUP SIZE top-k hint. Replica metrics are scraped roughly once per minute, so this is the bucket width in minutes.