Python · architecture
no-aggregation-in-store-query
python:no-aggregation-in-store-query Postgres store queries should not perform analytical aggregation.
- Code
- SARJ020
- Default
- error
- Fix
- none
- Languages
- python
Why
Analytical aggregation competes with transactional reads and is better served by the columnar mirror.
Fix
Run aggregation in ClickHouse or BigQuery and keep Postgres store queries focused on point or bounded reads.
Before / after
Executed by this rule’s unit tests.
Before
Postgres store query performs aggregation
QUERY = "SELECT COUNT(*) FROM call"
After
Postgres store query reads bounded rows
QUERY = "SELECT id FROM call ORDER BY created_at LIMIT 50"
Limits
- Only SQL string literals in recognized store modules are analyzed.
- Files and queries identified as ClickHouse or BigQuery are excluded.