Index conversation, message, memory and artifact foreign keys #76
Reference in New Issue
Block a user
Delete Branch "perf/fk-indexes"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Postgres had only primary keys on conversations, conversation_messages, user_memories and artifacts, so conversation loads/listing, the first-message check on every send, and memory/artifact lookups were sequential scans.
Adds: conversations(user_id, updated_at), conversation_messages(conversation_id, created_at), user_memories(user_id), artifacts(conversation_id), artifacts(message_id).
Migration 19 generated with aerich against a throwaway pgvector DB (not hand-written). Besides the indexes it contains the no-op JSONB re-casts aerich emits every run (as in migrations 16 and 18); verified they don't rewrite tables (relfilenode unchanged). Upgrade and downgrade both verified. Backward-compatible for blue-green.
🤖 Generated with Claude Code