Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions ddl/migrations/0220_chat_message_chat_created_idx.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-- Chat unread/message fanout queries constrain by chat_id and created_at.
-- The old partial index led with created_at and had 0 scans in production,
-- while chat_message lookups were producing heavy temp I/O. Lead with chat_id
-- so the per-chat range checks can use a small ordered slice.

CREATE INDEX CONCURRENTLY IF NOT EXISTS chat_message_chat_created_non_blast_idx
ON public.chat_message USING btree (chat_id, created_at, user_id)
WHERE blast_id IS NULL;

DROP INDEX CONCURRENTLY IF EXISTS public.chat_message_non_blast_created_at_idx;
Loading