Parent
Part of #414
Problem
History prune uses nested DELETE … SELECT … ORDER BY … OFFSET. Index is (connection_id, recorded_at DESC) but predicates use database_name IS NOT DISTINCT FROM ?, so prune can scan more rows than needed as history grows across DB buckets.
Evidence
lib/core/storage/local_db.dart (schema indexes + history prune)
Acceptance
Suggested fix
Add composite index; count then delete by id; keep per-connection/database caps.
Parent
Part of #414
Problem
History prune uses nested
DELETE … SELECT … ORDER BY … OFFSET. Index is(connection_id, recorded_at DESC)but predicates usedatabase_name IS NOT DISTINCT FROM ?, so prune can scan more rows than needed as history grows across DB buckets.Evidence
lib/core/storage/local_db.dart(schema indexes + history prune)Acceptance
(connection_id, database_name, recorded_at DESC)(or equivalent)Suggested fix
Add composite index; count then delete by id; keep per-connection/database caps.