mirror of
https://github.com/supabase/supabase.git
synced 2026-10-08 02:45:07 +03:00
## Problem The facet counts in the unified logs sidebar were slow to load. The query scanned the logs table about 14 times, once for each group of counts (the total, each log type, each level, and method, status, and pathname). ## Fix Count the facets that have few distinct values (total, log type, level, method, status) in a single scan instead of one scan each. Pathname stays on its own scan because it has too many distinct values to count that way. A facet you are filtering on still gets its own scan, so it can keep showing counts for its other values while the rest of the sidebar reflects the filter. This takes the common case from about 14 scans down to 3. The result shape is unchanged, so nothing else needed updating. Note: facet values with a count of zero are no longer returned. Only values that actually appear show up. ## How to test - Open Unified Logs for a project with the otelUnifiedLogs flag on. - Check that the sidebar counts (log type, level, method, status, pathname) and the total badge match what they showed before, and load faster. - Filter by a facet (e.g. log type) and confirm that facet still lists counts for its other values, while the other facets update to match the filter. - Run the unit tests in apps/studio for UnifiedLogs.queries. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Refactor** * Updated unified log counting to a more efficient single-pass SQL approach for facet and per-dimension counts. * Standardized log-type filtering behavior across unified queries and facet/count generation. * **Bug Fixes** * Improved “total/all” counts to correctly respect active filters, including correct source handling and default log-type exclusion. * **Refactor** * Limited facet displays to the top 20 values per facet; facet totals are now calculated from the retained rows. * **Tests** * Expanded SQL and filtering assertions to cover the new counting structure and facet row behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>