Context
Phase 5 Community Detection (epic #1222, issue #1228) added delete_expired_edges which filters on expired_at.
Problem
Migration 021 creates indexes on source_entity_id, target_entity_id, valid_to (partial), name, entity_type, and last_seen_at. There is no index on graph_edges.expired_at. The eviction query performs a full table scan:
DELETE FROM graph_edges
WHERE expired_at IS NOT NULL
AND expired_at < datetime('now', '-N days')
At 50K edges this is ~10ms (acceptable), but degrades with edge accumulation.
Suggested Fix
Add a follow-up migration:
CREATE INDEX idx_graph_edges_expired ON graph_edges(expired_at) WHERE expired_at IS NOT NULL;
Source
PERF-05 from Phase 5 performance analysis.
Context
Phase 5 Community Detection (epic #1222, issue #1228) added
delete_expired_edgeswhich filters onexpired_at.Problem
Migration 021 creates indexes on source_entity_id, target_entity_id, valid_to (partial), name, entity_type, and last_seen_at. There is no index on
graph_edges.expired_at. The eviction query performs a full table scan:At 50K edges this is ~10ms (acceptable), but degrades with edge accumulation.
Suggested Fix
Add a follow-up migration:
Source
PERF-05 from Phase 5 performance analysis.