mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-06-05 16:42:39 +00:00
core: improve chat list performance (indexes) (#3728)
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
|
||||
module Simplex.Chat.Migrations.M20240122_indexes where
|
||||
|
||||
import Database.SQLite.Simple (Query)
|
||||
import Database.SQLite.Simple.QQ (sql)
|
||||
|
||||
m20240122_indexes :: Query
|
||||
m20240122_indexes =
|
||||
[sql|
|
||||
CREATE INDEX idx_chat_items_contacts_created_at on chat_items (user_id, contact_id, created_at);
|
||||
CREATE INDEX idx_chat_items_contacts_item_status on chat_items (user_id, contact_id, item_status);
|
||||
CREATE INDEX idx_chat_items_groups_item_status on chat_items (user_id, group_id, item_status);
|
||||
CREATE INDEX idx_chat_items_notes_created_at on chat_items (user_id, note_folder_id, created_at);
|
||||
CREATE INDEX idx_chat_items_notes_item_status on chat_items (user_id, note_folder_id, item_status);
|
||||
|]
|
||||
|
||||
down_m20240122_indexes :: Query
|
||||
down_m20240122_indexes =
|
||||
[sql|
|
||||
DROP INDEX idx_chat_items_contacts_created_at;
|
||||
DROP INDEX idx_chat_items_contacts_item_status;
|
||||
DROP INDEX idx_chat_items_groups_item_status;
|
||||
DROP INDEX idx_chat_items_notes_created_at;
|
||||
DROP INDEX idx_chat_items_notes_item_status;
|
||||
|]
|
||||
@@ -829,3 +829,28 @@ CREATE INDEX idx_msg_deliveries_agent_msg_id ON "msg_deliveries"(
|
||||
CREATE INDEX chat_items_note_folder_id ON chat_items(note_folder_id);
|
||||
CREATE INDEX files_note_folder_id ON files(note_folder_id);
|
||||
CREATE INDEX note_folders_user_id ON note_folders(user_id);
|
||||
CREATE INDEX idx_chat_items_contacts_created_at on chat_items(
|
||||
user_id,
|
||||
contact_id,
|
||||
created_at
|
||||
);
|
||||
CREATE INDEX idx_chat_items_contacts_item_status on chat_items(
|
||||
user_id,
|
||||
contact_id,
|
||||
item_status
|
||||
);
|
||||
CREATE INDEX idx_chat_items_groups_item_status on chat_items(
|
||||
user_id,
|
||||
group_id,
|
||||
item_status
|
||||
);
|
||||
CREATE INDEX idx_chat_items_notes_created_at on chat_items(
|
||||
user_id,
|
||||
note_folder_id,
|
||||
created_at
|
||||
);
|
||||
CREATE INDEX idx_chat_items_notes_item_status on chat_items(
|
||||
user_id,
|
||||
note_folder_id,
|
||||
item_status
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user