Skip to content

perf(storage): SQL history index + prune without nested OFFSET delete #428

Description

@ZhuchkaTriplesix

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

  • Index supports (connection_id, database_name, recorded_at DESC) (or equivalent)
  • Prune deletes by primary key / simpler plan (no nested OFFSET scan when avoidable)
  • Migration covered; existing DBs upgrade cleanly

Suggested fix

Add composite index; count then delete by id; keep per-connection/database caps.

Metadata

Metadata

Labels

coreCore library logic and servicesperformanceTheme parser epic label: performancestorageTheme parser epic label: storage

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions