Skip to content

Fix stats query - #1072

Merged
j-chmielewski merged 5 commits into
release/2.1from
fix-stats-query
Jul 30, 2026
Merged

Fix stats query#1072
j-chmielewski merged 5 commits into
release/2.1from
fix-stats-query

Conversation

@j-chmielewski

Copy link
Copy Markdown
Contributor

Related issues: #1071, #1062, #874, #1062

Fixes excessive disk writes caused by an inefficient stats query:

  • Adds upload_diff / download_diff columns to location_stats and tunnel_stats, computed once at insert time
  • Rewrites the stats queries to read those precomputed diffs, replacing the window-function CTE with a plain GROUP BY aggregate - no more large SQLite temp files
  • Drops stats retention from 30 days to 28 hours, since the UI only ever charts the last 24h
  • Adds covering indexes on (location_id, collected_at) and (tunnel_id, collected_at) so the aggregate queries resolve via an index search instead of a full table scan

@j-chmielewski
j-chmielewski merged commit a201cb3 into release/2.1 Jul 30, 2026
9 of 11 checks passed
@j-chmielewski
j-chmielewski deleted the fix-stats-query branch July 30, 2026 07:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants