perf(store): index the six unindexed foreign keys (#1860)

Postgres does not index the referencing side of a foreign key, so deleting or updating a parent row scanned the child table once per referencing row for the six keys that had no matching index: identity aliases and subjects, org memberships and agents, installed package requirements, and the task a handoff came from. Migration 0074 adds one supporting index per key; the foreign-key integrity checks on the restored snapshot pass, with every one of the 17 constraints now covered.
This commit is contained in:
sam committed 2026-11-11 02:49:37 +11:00
1 parent dcc12582ce
commit 0033933a58
2 files changed
+23

No files matched your search

+4
View File
@@ -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
@@ -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;