diff --git a/CHANGELOG.md b/CHANGELOG.md index f201e3b17..12e73c3d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,10 @@ release's per-component sections are labelled beneath its heading. - Conversation titles are written from your message and Archie's reply, name what the conversation is about rather than the mood, and wait for an exchange with a subject. - Session memory never records passwords, tokens or other secrets, and adds only facts it does not already hold, so memory stops filling with restated duplicates. +### archie-state-store + +- Six foreign keys now have an index on the referencing column, so deleting a parent row looks its children up instead of scanning the child table: identity aliases and subjects, org memberships and agents, installed package requirements, and the task a handoff came from. + ## [1.62.0] - 2026-11-10 ### archied diff --git a/internal/infrastructure/postgres/migrations/0074_fk_indexes.sql b/internal/infrastructure/postgres/migrations/0074_fk_indexes.sql new file mode 100644 index 000000000..79953fd98 --- /dev/null +++ b/internal/infrastructure/postgres/migrations/0074_fk_indexes.sql @@ -0,0 +1,19 @@ +-- +goose Up +-- Postgres does not index the referencing side of a foreign key, so a parent +-- delete or key update scans the child table for each referencing row. These +-- indexes back the six child lookups that had no matching index. +CREATE INDEX idx_identity_aliases_identity_id ON identity_aliases (identity_id); +CREATE INDEX idx_identity_subjects_identity_id ON identity_subjects (identity_id); +CREATE INDEX idx_memberships_org_id ON memberships (org_id); +CREATE INDEX idx_org_agents_org_id ON org_agents (org_id); +CREATE INDEX idx_installed_package_requirements_org_id_required_name ON installed_package_requirements (org_id, required_name); +CREATE INDEX idx_tasks_handoff_from_task_id ON tasks (handoff_from_task_id); + +-- +goose Down + +DROP INDEX idx_tasks_handoff_from_task_id; +DROP INDEX idx_installed_package_requirements_org_id_required_name; +DROP INDEX idx_org_agents_org_id; +DROP INDEX idx_memberships_org_id; +DROP INDEX idx_identity_subjects_identity_id; +DROP INDEX idx_identity_aliases_identity_id;