Skip to content

Fix stats query - #1072

Open
j-chmielewski wants to merge 5 commits into
release/2.1from
fix-stats-query
Open

Fix stats query#1072
j-chmielewski wants to merge 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

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