mirror of
https://gh-proxy.org/https://github.com/klinsmaya/multica.git
synced 2026-11-08 01:16:45 +08:00
* fix(db): index chat session delete lookups Co-authored-by: multica-agent <[email protected]> * fix(db): address migration review Co-authored-by: multica-agent <[email protected]> --------- Co-authored-by: Sol-Boy <[email protected]> Co-authored-by: multica-agent <[email protected]>
12 lines
685 B
SQL
12 lines
685 B
SQL
-- Every chat_session delete runs the legacy agent_task_queue foreign-key
|
|
-- action with only chat_session_id in its predicate. The existing chat indexes
|
|
-- add status, session_id, or retired_session_id predicates and cannot serve
|
|
-- that lookup, so each deleted session scans the global task table.
|
|
--
|
|
-- Keep created_at in the key so this broader index also covers migration 465's
|
|
-- cancelled-chat pointer lookup. Migration 473 drops that narrower index only
|
|
-- after this concurrent build has completed successfully.
|
|
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_agent_task_queue_chat_session
|
|
ON agent_task_queue (chat_session_id, created_at DESC)
|
|
WHERE chat_session_id IS NOT NULL;
|