diff --git a/src/Simplex/Chat/Library/Subscriber.hs b/src/Simplex/Chat/Library/Subscriber.hs index 9888e5e74e..49d8c4f094 100644 --- a/src/Simplex/Chat/Library/Subscriber.hs +++ b/src/Simplex/Chat/Library/Subscriber.hs @@ -2714,7 +2714,6 @@ processAgentMessageConn vr user@User {userId} corrId agentConnId agentMessage = case chatMsgEvent of XInfo p -> do ct <- withStore $ \db -> createDirectContact db user conn' p - -- TODO create banner toView $ CEvtContactConnecting user ct pure (conn', False) XGrpLinkInv glInv -> do diff --git a/src/Simplex/Chat/Store/SQLite/Migrations/agent_query_plans.txt b/src/Simplex/Chat/Store/SQLite/Migrations/agent_query_plans.txt index 8b727fde98..ee717e71f5 100644 --- a/src/Simplex/Chat/Store/SQLite/Migrations/agent_query_plans.txt +++ b/src/Simplex/Chat/Store/SQLite/Migrations/agent_query_plans.txt @@ -1135,6 +1135,10 @@ Query: UPDATE snd_file_chunk_replicas SET replica_status = ?, updated_at = ? WHE Plan: SEARCH snd_file_chunk_replicas USING INTEGER PRIMARY KEY (rowid=?) +Query: UPDATE snd_files SET deleted = 1, updated_at = ? WHERE snd_file_id = ? +Plan: +SEARCH snd_files USING INTEGER PRIMARY KEY (rowid=?) + Query: UPDATE snd_files SET prefix_path = NULL, status = ?, updated_at = ? WHERE snd_file_id = ? Plan: SEARCH snd_files USING INTEGER PRIMARY KEY (rowid=?) diff --git a/src/Simplex/Chat/Store/SQLite/Migrations/chat_query_plans.txt b/src/Simplex/Chat/Store/SQLite/Migrations/chat_query_plans.txt index 101104c975..70def348fa 100644 --- a/src/Simplex/Chat/Store/SQLite/Migrations/chat_query_plans.txt +++ b/src/Simplex/Chat/Store/SQLite/Migrations/chat_query_plans.txt @@ -3739,24 +3739,6 @@ SEARCH commands USING COVERING INDEX idx_commands_connection_id (connection_id=? SEARCH messages USING COVERING INDEX idx_messages_connection_id (connection_id=?) SEARCH snd_files USING COVERING INDEX idx_snd_files_connection_id (connection_id=?) -Query: - DELETE FROM connections WHERE connection_id IN ( - SELECT connection_id - FROM connections c - JOIN user_contact_links uc USING (user_contact_link_id) - WHERE uc.user_id = ? AND uc.group_id = ? - ) - -Plan: -SEARCH connections USING INTEGER PRIMARY KEY (rowid=?) -LIST SUBQUERY 1 -SEARCH uc USING INDEX idx_user_contact_links_group_id (group_id=?) -SEARCH c USING COVERING INDEX idx_connections_user_contact_link_id (user_contact_link_id=?) -SEARCH msg_deliveries USING COVERING INDEX idx_msg_deliveries_agent_msg_id (connection_id=?) -SEARCH commands USING COVERING INDEX idx_commands_connection_id (connection_id=?) -SEARCH messages USING COVERING INDEX idx_messages_connection_id (connection_id=?) -SEARCH snd_files USING COVERING INDEX idx_snd_files_connection_id (connection_id=?) - Query: DELETE FROM connections WHERE connection_id IN ( SELECT connection_id @@ -3840,26 +3822,6 @@ SEARCH group_members USING COVERING INDEX idx_group_members_member_profile_id (m SEARCH group_members USING COVERING INDEX idx_group_members_contact_profile_id (contact_profile_id=?) SEARCH contacts USING COVERING INDEX idx_contacts_contact_profile_id (contact_profile_id=?) -Query: - DELETE FROM contact_profiles - WHERE contact_profile_id in ( - SELECT cr.contact_profile_id - FROM contact_requests cr - JOIN user_contact_links uc USING (user_contact_link_id) - WHERE uc.user_id = ? AND uc.group_id = ? - ) - -Plan: -SEARCH contact_profiles USING INTEGER PRIMARY KEY (rowid=?) -LIST SUBQUERY 1 -SEARCH uc USING INDEX idx_user_contact_links_group_id (group_id=?) -SEARCH cr USING INDEX idx_contact_requests_user_contact_link_id (user_contact_link_id=?) -SEARCH contact_requests USING COVERING INDEX idx_contact_requests_contact_profile_id (contact_profile_id=?) -SEARCH connections USING COVERING INDEX idx_connections_custom_user_profile_id (custom_user_profile_id=?) -SEARCH group_members USING COVERING INDEX idx_group_members_member_profile_id (member_profile_id=?) -SEARCH group_members USING COVERING INDEX idx_group_members_contact_profile_id (contact_profile_id=?) -SEARCH contacts USING COVERING INDEX idx_contacts_contact_profile_id (contact_profile_id=?) - Query: DELETE FROM contact_profiles WHERE user_id = ? AND contact_profile_id = ? @@ -3967,30 +3929,6 @@ SEARCH groups USING COVERING INDEX sqlite_autoindex_groups_1 (user_id=? AND loca SEARCH contacts USING COVERING INDEX sqlite_autoindex_contacts_1 (user_id=? AND local_display_name=?) SEARCH users USING INTEGER PRIMARY KEY (rowid=?) -Query: - DELETE FROM display_names - WHERE user_id = ? - AND local_display_name in ( - SELECT cr.local_display_name - FROM contact_requests cr - JOIN user_contact_links uc USING (user_contact_link_id) - WHERE uc.user_id = ? AND uc.group_id = ? - ) - AND local_display_name NOT IN (SELECT local_display_name FROM users WHERE user_id = ?) - -Plan: -SEARCH display_names USING PRIMARY KEY (user_id=? AND local_display_name=?) -LIST SUBQUERY 1 -SEARCH uc USING INDEX idx_user_contact_links_group_id (group_id=?) -SEARCH cr USING INDEX idx_contact_requests_user_contact_link_id (user_contact_link_id=?) -LIST SUBQUERY 2 -SEARCH users USING INTEGER PRIMARY KEY (rowid=?) -SEARCH contact_requests USING COVERING INDEX sqlite_autoindex_contact_requests_1 (user_id=? AND local_display_name=?) -SEARCH group_members USING COVERING INDEX idx_group_members_user_id_local_display_name (user_id=? AND local_display_name=?) -SEARCH groups USING COVERING INDEX sqlite_autoindex_groups_1 (user_id=? AND local_display_name=?) -SEARCH contacts USING COVERING INDEX sqlite_autoindex_contacts_1 (user_id=? AND local_display_name=?) -SEARCH users USING INTEGER PRIMARY KEY (rowid=?) - Query: DELETE FROM display_names WHERE user_id = ? AND local_display_name = ( @@ -4110,6 +4048,13 @@ LIST SUBQUERY 1 SEARCH groups USING INTEGER PRIMARY KEY (rowid=?) SEARCH groups USING COVERING INDEX idx_groups_group_profile_id (group_profile_id=?) +Query: + INSERT INTO calls + (contact_id, shared_call_id, call_uuid, chat_item_id, call_state, call_ts, user_id, created_at, updated_at) + VALUES (?,?,?,?,?,?,?,?,?) + +Plan: + Query: INSERT INTO chat_item_moderations (group_id, moderator_member_id, item_member_id, shared_msg_id, created_by_msg_id, moderated_at) @@ -4224,6 +4169,14 @@ Query: Plan: SEARCH group_members USING INDEX sqlite_autoindex_group_members_1 (group_id=?) +Query: + SELECT chat_item_id, timed_ttl + FROM chat_items + WHERE user_id = ? AND contact_id = ? AND item_status = ? AND timed_ttl IS NOT NULL AND timed_delete_at IS NULL + +Plan: +SEARCH chat_items USING INDEX idx_chat_items_contacts (user_id=? AND contact_id=? AND item_status=?) + Query: SELECT chat_item_id, timed_ttl FROM chat_items @@ -4302,6 +4255,13 @@ Query: Plan: SEARCH chat_items USING INTEGER PRIMARY KEY (rowid=?) +Query: + UPDATE chat_items SET item_status = ?, updated_at = ? + WHERE user_id = ? AND contact_id = ? AND item_status = ? + +Plan: +SEARCH chat_items USING INDEX idx_chat_items_contacts (user_id=? AND contact_id=? AND item_status=?) + Query: UPDATE chat_items SET item_status = ?, updated_at = ? WHERE user_id = ? AND contact_id = ? AND item_status = ? AND chat_item_id = ? @@ -5267,10 +5227,6 @@ Query: SELECT chat_item_id FROM chat_items WHERE user_id = ? AND group_id = ? Plan: SEARCH chat_items USING COVERING INDEX idx_chat_items_group_scope_item_ts (user_id=? AND group_id=? AND group_scope_tag=? AND group_scope_group_member_id=?) -Query: SELECT chat_item_id FROM chat_items WHERE user_id = ? AND group_id = ? AND group_scope_tag IS NULL AND group_scope_group_member_id IS NULL AND LOWER(item_text) LIKE '%' || LOWER(?) || '%' ORDER BY item_ts DESC, chat_item_id DESC LIMIT ? -Plan: -SEARCH chat_items USING INDEX idx_chat_items_group_scope_item_ts (user_id=? AND group_id=? AND group_scope_tag=? AND group_scope_group_member_id=?) - Query: SELECT chat_item_id FROM chat_items WHERE user_id = ? AND group_id = ? AND group_scope_tag IS NULL AND group_scope_group_member_id IS NULL ORDER BY item_ts DESC, chat_item_id DESC LIMIT ? Plan: SEARCH chat_items USING COVERING INDEX idx_chat_items_group_scope_item_ts (user_id=? AND group_id=? AND group_scope_tag=? AND group_scope_group_member_id=?) @@ -5288,6 +5244,10 @@ Error: SQLite3 returned ErrorError while attempting to perform prepare "explain Query: DELETE FROM app_settings Plan: +Query: DELETE FROM calls WHERE user_id = ? AND contact_id = ? +Plan: +SEARCH calls USING INDEX idx_calls_contact_id (contact_id=?) + Query: DELETE FROM chat_item_mentions WHERE chat_item_id = ? Plan: SEARCH chat_item_mentions USING COVERING INDEX idx_chat_item_mentions_chat_item_id (chat_item_id=?) @@ -5615,13 +5575,6 @@ Query: DELETE FROM snd_file_chunks WHERE file_id = ? AND connection_id = ? Plan: SEARCH snd_file_chunks USING COVERING INDEX idx_snd_file_chunks_file_id_connection_id (file_id=? AND connection_id=?) -Query: DELETE FROM user_contact_links WHERE user_id = ? AND group_id = ? -Plan: -SEARCH user_contact_links USING INDEX idx_user_contact_links_group_id (group_id=?) -SEARCH contact_requests USING COVERING INDEX idx_contact_requests_user_contact_link_id (user_contact_link_id=?) -SEARCH connections USING COVERING INDEX idx_connections_via_user_contact_link (via_user_contact_link=?) -SEARCH connections USING COVERING INDEX idx_connections_user_contact_link_id (user_contact_link_id=?) - Query: DELETE FROM user_contact_links WHERE user_id = ? AND local_display_name = '' AND group_id IS NULL Plan: SEARCH user_contact_links USING INDEX sqlite_autoindex_user_contact_links_1 (user_id=? AND local_display_name=?) @@ -6028,6 +5981,10 @@ Query: UPDATE chat_items SET item_status = ?, updated_at = ? WHERE user_id = ? A Plan: SEARCH chat_items USING INTEGER PRIMARY KEY (rowid=?) +Query: UPDATE chat_items SET item_status = ?, updated_at = ? WHERE user_id = ? AND item_status = ? +Plan: +SEARCH chat_items USING INDEX idx_chat_items_user_id_item_status (user_id=? AND item_status=?) + Query: UPDATE chat_items SET timed_delete_at = ? WHERE user_id = ? AND contact_id = ? AND chat_item_id = ? Plan: SEARCH chat_items USING INTEGER PRIMARY KEY (rowid=?) @@ -6124,6 +6081,10 @@ Query: UPDATE contacts SET unread_chat = ?, updated_at = ? WHERE user_id = ? AND Plan: SEARCH contacts USING INTEGER PRIMARY KEY (rowid=?) +Query: UPDATE contacts SET unread_chat = ?, updated_at = ? WHERE user_id = ? AND unread_chat = ? +Plan: +SEARCH contacts USING INDEX idx_contacts_chat_ts (user_id=?) + Query: UPDATE contacts SET user_preferences = ?, updated_at = ? WHERE user_id = ? AND contact_id = ? Plan: SEARCH contacts USING INTEGER PRIMARY KEY (rowid=?) @@ -6244,9 +6205,9 @@ Query: UPDATE groups SET ui_themes = ?, updated_at = ? WHERE user_id = ? AND gro Plan: SEARCH groups USING INTEGER PRIMARY KEY (rowid=?) -Query: UPDATE groups SET unread_chat = ?, updated_at = ? WHERE user_id = ? AND group_id = ? +Query: UPDATE groups SET unread_chat = ?, updated_at = ? WHERE user_id = ? AND unread_chat = ? Plan: -SEARCH groups USING INTEGER PRIMARY KEY (rowid=?) +SEARCH groups USING INDEX idx_groups_chat_ts (user_id=?) Query: UPDATE groups SET user_member_profile_sent_at = ? WHERE user_id = ? AND group_id = ? Plan: @@ -6264,6 +6225,10 @@ Query: UPDATE note_folders SET unread_chat = ?, updated_at = ? WHERE user_id = ? Plan: SEARCH note_folders USING INTEGER PRIMARY KEY (rowid=?) +Query: UPDATE note_folders SET unread_chat = ?, updated_at = ? WHERE user_id = ? AND unread_chat = ? +Plan: +SEARCH note_folders USING INDEX note_folders_user_id (user_id=?) + Query: UPDATE rcv_files SET agent_rcv_file_deleted = 1, updated_at = ? WHERE file_id = ? Plan: SEARCH rcv_files USING INTEGER PRIMARY KEY (rowid=?)