mirror of
https://github.com/supabase/supabase.git
synced 2026-10-09 19:35:06 +03:00
Replace the OTEL facet count query's 13x UNION ALL with a single-pass arrayJoin "explode" over `logs`. Each row is fanned out into one row per dimension and `multiIf` picks that dimension's value, so all facet counts plus the total are computed in one scan instead of 13. The output (dimension, value, count) shape is unchanged, so the consumer in unified-logs-count-query.ts needs no changes. Reuses the existing LOG_TYPE_EXPR / LEVEL_EXPR / STATUS_EXPR expressions. Based on the single-scan SQL shape Chase verified against the logs.all.otel endpoint (no CTEs / window fns / tuples / subqueries). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>