Skip to content

Load only the latest checks for monitor bars - #90

Merged
tomschlick merged 1 commit into
masterfrom
feature/faster-monitor-list-bars-6888
Oct 2, 2026
Merged

tomschlick merged 1 commit into
masterfrom
feature/faster-monitor-list-bars-6888

Conversation

@tomschlick

Copy link
Copy Markdown
Member

Summary

The monitors list was slow because each page ranked every retained check for the monitors on that page, then kept 40 bars. At a 60s interval and 30-day retention that is on the order of 40k rows per monitor.

LoadRecentCheckResults now loads the latest 40 checks per monitor with ORDER BY checked_at DESC, id DESC LIMIT, wrapped so the limit applies on both SQLite and Postgres, and chunked so a status page with a few hundred monitors stays under SQLite's compound-select cap. A new (monitor_id, checked_at, id) index lets that limit stop early. The redundant (monitor_id, checked_at) index is dropped.

Bar markup is unchanged: newest 40 checks, oldest first, with the same tooltips.

Test plan

  • LoadRecentCheckResultsTest covers a monitor over the limit, one under it, and one with no checks, oldest-first
  • Monitor list still renders 39 up bars, 1 down bar, and tooltip text
  • Architecture tests pass
Open in Web Open in Cursor 

The list ranked every retained check for each monitor just to keep 40 bars. Query each monitor with an indexed limit instead, and index monitor, time, and id so that limit can stop early.

Co-authored-by: Tom Schlick <tom@schlick.email>
@tomschlick
tomschlick marked this pull request as ready for review October 2, 2026 14:37
@tomschlick
tomschlick merged commit 545a0b6 into master Oct 2, 2026
2 checks passed
@tomschlick
tomschlick deleted the feature/faster-monitor-list-bars-6888 branch October 2, 2026 14:38
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.

1 participant