Console pages (monitors, incidents, monitor details, status page editor) became slow for organizations with many monitors.
Cause
Every page showing monitor status ran one loader that read, for all monitors of the organization:
the newest result per monitor and region, by scanning a day of raw results,
the bars of the selected range, from raw results up to 24h, although only one page of monitors is shown,
when each monitor first reported, scanning two days of raw results.
In addition, monitor, region and incident queries relied on row security alone, which keeps Postgres from using an index: they filtered the whole table across all organizations.
Changes
latest_results (migration 00055): the newest result per monitor and region, upserted with every stored result. A late result does not replace a newer one. The migration fills the table from the last day.
Bars are loaded only for the monitors a page shows. Search and filter load them only for the hits.
First data is loaded per monitor on its page. The monitor list asks only for the organization's earliest data, through an index lookup per monitor.
ListMonitors, AllMonitorRegions, OpenIncidents and IncidentsSince name the organization. New indexes monitor_regions (org_id) and incidents (org_id) WHERE open.
Public status pages read the latest results and hourly buckets of their own monitors only.
Status page editor: only monitors on the page carry a group select and label field. Others get them from a <template> when ticked. A filter field appears above 15 monitors, and "Add all" ticks only visible monitors.
Measured (test DB, 3000 monitors, 2 h of results each)
Page
before
after
Monitors /
~900 ms
~240 ms
Incidents
~1000 ms
~270 ms
Monitor detail
—
~160 ms
Status page editor HTML
2.2 MB
1.0 MB (50 on page)
In production the gain is larger: the old queries grew with the number of results (1440 per monitor and region per day at a 1-minute interval). The seed had only 120.
Public status pages
Status page servers fetch snapshots with a 15 s timeout. For large organizations the build took longer (prod logs: /agent/v1/pages 500 after 15 s, context canceled), so pages such as /hetzner kept serving an old copy with the "live updates unavailable" notice. The build spent its time on the same full-day scan of raw results for every monitor of the organization.
The snapshot reads latest_results of its own monitors (see above) and incidents by organization, which uses incidents_org_idx.
Status page servers asking for the same page at once share one build, which does not end when one of them gives up.
Measured on the test DB (1000 monitors, a page with 200 and component details, 90 days of history): ~2.4 s → ~0.23 s per snapshot. The old time grew with the results per day. The new time does not depend on them.
Tests
TestLatestResultsKeepTheNewest: batch, late result, newer result, API and page.
The page editor test checks that only the template and included monitors carry fields.
regionwatch_test also seeds latest_results, as ingest does.
Editor JS checked in headless Chromium: ticking adds fields once, the filter hides rows, "Add all" acts on visible rows only.
go test -p 1 ./... green, golangci-lint v2.15.0: 0 issues. Migration and live ingest checked on the dev stack.
Console pages (monitors, incidents, monitor details, status page editor) became slow for organizations with many monitors.
## Cause
Every page showing monitor status ran one loader that read, for **all** monitors of the organization:
- the newest result per monitor and region, by scanning a day of raw results,
- the bars of the selected range, from raw results up to 24h, although only one page of monitors is shown,
- when each monitor first reported, scanning two days of raw results.
In addition, monitor, region and incident queries relied on row security alone, which keeps Postgres from using an index: they filtered the whole table across all organizations.
## Changes
- **`latest_results`** (migration 00055): the newest result per monitor and region, upserted with every stored result. A late result does not replace a newer one. The migration fills the table from the last day.
- Bars are loaded only for the monitors a page shows. Search and filter load them only for the hits.
- First data is loaded per monitor on its page. The monitor list asks only for the organization's earliest data, through an index lookup per monitor.
- `ListMonitors`, `AllMonitorRegions`, `OpenIncidents` and `IncidentsSince` name the organization. New indexes `monitor_regions (org_id)` and `incidents (org_id) WHERE open`.
- Public status pages read the latest results and hourly buckets of their own monitors only.
- Status page editor: only monitors on the page carry a group select and label field. Others get them from a `<template>` when ticked. A filter field appears above 15 monitors, and "Add all" ticks only visible monitors.
## Measured (test DB, 3000 monitors, 2 h of results each)
| Page | before | after |
|---|---|---|
| Monitors `/` | ~900 ms | ~240 ms |
| Incidents | ~1000 ms | ~270 ms |
| Monitor detail | — | ~160 ms |
| Status page editor HTML | 2.2 MB | 1.0 MB (50 on page) |
In production the gain is larger: the old queries grew with the number of results (1440 per monitor and region per day at a 1-minute interval). The seed had only 120.
## Public status pages
Status page servers fetch snapshots with a 15 s timeout. For large organizations the build took longer (prod logs: `/agent/v1/pages` 500 after 15 s, `context canceled`), so pages such as `/hetzner` kept serving an old copy with the "live updates unavailable" notice. The build spent its time on the same full-day scan of raw results for every monitor of the organization.
- The snapshot reads `latest_results` of its own monitors (see above) and incidents by organization, which uses `incidents_org_idx`.
- Status page servers asking for the same page at once share one build, which does not end when one of them gives up.
Measured on the test DB (1000 monitors, a page with 200 and component details, 90 days of history): **~2.4 s → ~0.23 s** per snapshot. The old time grew with the results per day. The new time does not depend on them.
## Tests
- `TestLatestResultsKeepTheNewest`: batch, late result, newer result, API and page.
- The page editor test checks that only the template and included monitors carry fields.
- `regionwatch_test` also seeds `latest_results`, as ingest does.
- Editor JS checked in headless Chromium: ticking adds fields once, the filter hides rows, "Add all" acts on visible rows only.
- `go test -p 1 ./...` green, golangci-lint v2.15.0: 0 issues. Migration and live ingest checked on the dev stack.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
The editor rendered a group select and label field for every monitor of
the organization, about 2 MB of HTML for 3000 monitors. Only monitors on
the page carry their fields now; others get them from a template when
ticked. A filter field narrows long lists, and "Add all" ticks only the
monitors it leaves visible.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
Every console page that shows monitor status (monitors, incidents,
monitor details, evidence) went through one loader that read, for all of
the organization's monitors:
- the newest result per monitor and region, by scanning a day of raw
results;
- the bars of the selected range, from raw results for ranges up to 24h,
though only one page of monitors is shown;
- when each monitor first reported, scanning two days of results.
With 3000 monitors that took about a second, growing with the number of
results. Now:
- latest_results keeps the newest result per monitor and region,
updated as results are stored (migration 00055 fills it from the last
day);
- bars are loaded only for the monitors a page shows;
- first data is loaded per monitor on its page, and the monitor list asks
only for the organization's earliest data, by index;
- monitor, region and incident queries name the organization, so their
indexes are used instead of row security filtering whole tables.
Public status pages also read only their own monitors' latest results
and hourly buckets instead of the whole organization's.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
The snapshot read the incidents of a page without the organization, which
row level security keeps from using an index, and every status page
server asking for a page built it on its own. Snapshots now filter by the
organization and servers asking at the same time share one build, which
does not end when one of them gives up.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Console pages (monitors, incidents, monitor details, status page editor) became slow for organizations with many monitors.
Cause
Every page showing monitor status ran one loader that read, for all monitors of the organization:
In addition, monitor, region and incident queries relied on row security alone, which keeps Postgres from using an index: they filtered the whole table across all organizations.
Changes
latest_results(migration 00055): the newest result per monitor and region, upserted with every stored result. A late result does not replace a newer one. The migration fills the table from the last day.ListMonitors,AllMonitorRegions,OpenIncidentsandIncidentsSincename the organization. New indexesmonitor_regions (org_id)andincidents (org_id) WHERE open.<template>when ticked. A filter field appears above 15 monitors, and "Add all" ticks only visible monitors.Measured (test DB, 3000 monitors, 2 h of results each)
/In production the gain is larger: the old queries grew with the number of results (1440 per monitor and region per day at a 1-minute interval). The seed had only 120.
Public status pages
Status page servers fetch snapshots with a 15 s timeout. For large organizations the build took longer (prod logs:
/agent/v1/pages500 after 15 s,context canceled), so pages such as/hetznerkept serving an old copy with the "live updates unavailable" notice. The build spent its time on the same full-day scan of raw results for every monitor of the organization.latest_resultsof its own monitors (see above) and incidents by organization, which usesincidents_org_idx.Measured on the test DB (1000 monitors, a page with 200 and component details, 90 days of history): ~2.4 s → ~0.23 s per snapshot. The old time grew with the results per day. The new time does not depend on them.
Tests
TestLatestResultsKeepTheNewest: batch, late result, newer result, API and page.regionwatch_testalso seedslatest_results, as ingest does.go test -p 1 ./...green, golangci-lint v2.15.0: 0 issues. Migration and live ingest checked on the dev stack.🤖 Generated with Claude Code
https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3