History query performance, indexing, and Postgres-tier tests #141
Labels
No labels
area:ai
area:ci-cd
area:notifications
area:observability
area:public-pages
backlog
bug
duplicate
enhancement
help wanted
invalid
question
type:decision
type:feature
type:infra
type:maintenance
type:security
v1.0.1
v1.1.0
v1.2.0
v1.3.0
v2.0.0
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
rbrooks/WeatherBot#141
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Parent: #22.
Concrete existing problem
/stats(app/main.py:333-341) runs one unbounded query over the entire retained history for every visible location, then aggregates in Python withcollections.Counter(:344-383). The Python aggregation is deliberate and documented — there is no portable cross-dialect "group by calendar month" between Postgresdate_truncand the SQLite test tier'sstrftime.At today's 90-day retention that is tolerable. At a 13-month horizon, with the Explorer's added capture volume, it is not.
Tasks
/statsquery by date range and add a range selector; decide whether/statsfolds into the Explorer's calendar view or stays a separate summary page.sent_alerts,nws_alert_snapshots, and the lightning archive need time-based partitioning at 13 months, or whether plain indexes suffice. Measure before adding the complexity.@pytest.mark.postgres) for the JSONB-heavy and date-bucketing queries SQLite cannot express — the existing two-tier split is exactly why/statsaggregates in Python today.Picking this up — last engineering item of the milestone, now that all Explorer query shapes are on main (#135, #137–#140, #142). Plan per the task list: bound
/statswith a range selector (kept as a separate summary page — the unbounded scan is the problem, not the page); index audit across the new access patterns (one known gap going in:sent_alerts.sent_athas no index despite being the stats/history slice key); the partitioning question answered by measurement — seeded multi-month fixture +EXPLAIN ANALYZEagainst real Postgres on the dev host, numbers recorded here before any complexity is added; Postgres-tier tests for the date-bucketing/JSONB queries SQLite can't express; and the #174 order-dependent flake hunted to its root cause. PR to follow.