Finding
Unpushed Flux pivot() before aggregateWindow() allocated 22 GiB per Grafana refresh
Fleet telemetry dashboards called pivot() on raw 5-second points across 14 days before windowing, disabling TSM storage pushdown and pulling 38 million points into Go heap. Reordering the pipeline (and moving key panels to InfluxQL plus a 5m downsampled bucket) cut query time from 14.2s to 42ms.
1. Pushdown-safe Flux refactor & equivalent native InfluxQL query
flux pushdown vs native influxql
// Pushdown-safe Flux: filter tags + aggregateWindow() BEFORE pivot()
from(bucket: "telemetry_5m_rollup")
|> range(start: -14d)
|> filter(fn: (r) => r._measurement == "inverter_metrics" and r.site_id == "us-west-04")
|> filter(fn: (r) => r._field == "kw_out" or r._field == "temp_c")
|> aggregateWindow(every: 1h, fn: mean, createEmpty: false)
|> pivot(rowKey: ["_time"], columnKey: ["_field"], valueColumn: "_value")
-- Equivalent Native InfluxQL (executes directly on TSM/IOx iterators):
SELECT MEAN("kw_out") AS "kw_out", MEAN("temp_c") AS "temp_c"
FROM "telemetry_5m_rollup"."autogen"."inverter_metrics"
WHERE time >= now() - 14d AND "site_id" = 'us-west-04'
GROUP BY time(1h), "inverter_id" FILL(none)2. InfluxDB 2.x config.toml: Memory, WAL, and query concurrency guardrails
/etc/influxdb/config.toml · production tuning
storage-cache-max-memory-size = 6442450944 # 6 GiB WAL cache ceiling storage-cache-snapshot-memory-size = 104857600 # 100 MiB TSM snapshot flush storage-compact-full-write-cold-duration = "8h" # Wait 8h before full L4 compaction storage-compact-throughput = 134217728 # 128 MiB/s sustained compaction storage-compact-throughput-burst = 201326592 # 192 MiB/s burst compaction storage-series-id-set-cache-size = 500 # Cache hot tag filter bitmaps query-concurrency = 32 query-max-memory-bytes = 8589934592 # 8 GiB cap across active queries







