06/08 Optimize queries with indexes

This commit is contained in:
2026-06-08 14:45:04 -04:00
parent 9eec6ff94a
commit a548cc0b8e
5 changed files with 98 additions and 2 deletions
+12 -1
View File
@@ -559,7 +559,18 @@ phase1_projects_roles → phase6_features → phase7_mobile_api → phase8_notif
→ phase17_notification_event_type
→ phase18_issue_reported_by
→ phase19_issue_mobile_photos
→ phase20_inspector_assignments ← HEAD
→ phase20_inspector_assignments
→ phase21_performance_indexes ← HEAD
```
### phase21_performance_indexes
Adds four composite indexes covering the highest-traffic multi-column query patterns: `(facility_id, inspection_date)` and `(inspector_id, inspection_date)` and `(status, inspection_date)` on `inspections`; `(facility_id, status)` on `issues`. All single-column indexes already exist from phase12. Uses `INFORMATION_SCHEMA.STATISTICS` existence check — safe to re-run.
**Deploy order for phase21:**
```bash
flask db upgrade
sudo systemctl restart gunicorn
```
### phase19_issue_mobile_photos