fix: ship persistent bgp ai briefs and optimize bgp queries
This commit is contained in:
15
rules.md
15
rules.md
@@ -224,3 +224,18 @@ class BaseCollector:
|
||||
- Dependency injection for testability
|
||||
- Feature flags for incomplete features
|
||||
- Use config files for environment-specific settings
|
||||
|
||||
---
|
||||
|
||||
## Query Performance - MANDATORY
|
||||
|
||||
- **NEVER** load whole tables into Python just to do filtering, pagination, counting, dedupe, or summary aggregation
|
||||
- Filters, sorting, pagination, `count`, `distinct`, and grouped statistics **MUST** be pushed down to the database whenever the ORM/query builder can express them
|
||||
- Summary/dashboard endpoints should prefer dedicated aggregate queries or aggregate endpoints, not multiple full-table scans
|
||||
- For hot paths, avoid selecting large JSON/text payload columns unless the response really needs them
|
||||
- If an endpoint returns a list, default to database-side pagination instead of `scalars().all()` followed by Python slicing
|
||||
- When you suspect a query is slow, first check for:
|
||||
- full-table ORM loads
|
||||
- Python-side post-filtering
|
||||
- repeated summary queries that can be merged
|
||||
- repeated per-request recomputation that should be cached or aggregated once
|
||||
|
||||
Reference in New Issue
Block a user