diff --git a/src/Simplex/Chat/Store/Postgres/Migrations/chat_schema.sql b/src/Simplex/Chat/Store/Postgres/Migrations/chat_schema.sql index b410ba4ca9..aa945f34b3 100644 --- a/src/Simplex/Chat/Store/Postgres/Migrations/chat_schema.sql +++ b/src/Simplex/Chat/Store/Postgres/Migrations/chat_schema.sql @@ -516,7 +516,10 @@ CREATE TABLE test_chat_schema.chat_items ( fwd_from_group_link bytea, fwd_from_public_group_id bytea, fwd_from_member_id bytea, - fwd_from_shared_msg_id bytea + fwd_from_shared_msg_id bytea, + feed_id bigint, + feed_item_id bigint, + item_feed smallint DEFAULT 0 NOT NULL ); @@ -800,7 +803,8 @@ CREATE TABLE test_chat_schema.contacts ( grp_direct_inv_from_group_member_id bigint, grp_direct_inv_from_member_conn_id bigint, grp_direct_inv_started_connection smallint DEFAULT 0 NOT NULL, - chat_layout text + chat_layout text, + drop_feed smallint DEFAULT 0 NOT NULL ); @@ -910,6 +914,57 @@ ALTER TABLE test_chat_schema.extra_xftp_file_descriptions ALTER COLUMN extra_fil +CREATE TABLE test_chat_schema.feed_jobs ( + feed_job_id bigint NOT NULL, + feed_id bigint NOT NULL, + chat_item_id bigint NOT NULL, + worker_scope text NOT NULL, + action_tag text NOT NULL, + message_ids text, + cursor_id bigint, + job_status text NOT NULL, + job_err_reason text, + failed smallint DEFAULT 0 NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL +); + + + +ALTER TABLE test_chat_schema.feed_jobs ALTER COLUMN feed_job_id ADD GENERATED ALWAYS AS IDENTITY ( + SEQUENCE NAME test_chat_schema.feed_jobs_feed_job_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1 +); + + + +CREATE TABLE test_chat_schema.feeds ( + feed_id bigint NOT NULL, + user_id bigint NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + chat_ts timestamp with time zone DEFAULT now() NOT NULL, + favorite smallint DEFAULT 0 NOT NULL, + unread_chat smallint DEFAULT 0 NOT NULL +); + + + +ALTER TABLE test_chat_schema.feeds ALTER COLUMN feed_id ADD GENERATED ALWAYS AS IDENTITY ( + SEQUENCE NAME test_chat_schema.feeds_feed_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1 +); + + + CREATE TABLE test_chat_schema.file_badge_proofs ( badge_proof_id bigint NOT NULL, file_id bigint NOT NULL, @@ -966,7 +1021,8 @@ CREATE TABLE test_chat_schema.files ( file_digest bytea, file_expires_at timestamp with time zone, file_max_size bigint, - file_badge_status text + file_badge_status text, + feed_id bigint ); @@ -1225,7 +1281,8 @@ CREATE TABLE test_chat_schema.groups ( group_domain_verified smallint, stored_roster_version bigint, applied_complete_roster_version bigint, - relay_request_public_group_id bytea + relay_request_public_group_id bytea, + drop_feed smallint DEFAULT 0 NOT NULL ); @@ -1299,7 +1356,8 @@ CREATE TABLE test_chat_schema.messages ( forwarded_by_group_member_id bigint, broker_ts timestamp with time zone, msg_chat_binding text, - msg_signatures bytea + msg_signatures bytea, + feed_id bigint ); @@ -1999,6 +2057,16 @@ ALTER TABLE ONLY test_chat_schema.extra_xftp_file_descriptions +ALTER TABLE ONLY test_chat_schema.feed_jobs + ADD CONSTRAINT feed_jobs_pkey PRIMARY KEY (feed_job_id); + + + +ALTER TABLE ONLY test_chat_schema.feeds + ADD CONSTRAINT feeds_pkey PRIMARY KEY (feed_id); + + + ALTER TABLE ONLY test_chat_schema.file_badge_proofs ADD CONSTRAINT file_badge_proofs_pkey PRIMARY KEY (badge_proof_id); @@ -2384,6 +2452,22 @@ CREATE UNIQUE INDEX idx_chat_items_direct_shared_msg_id ON test_chat_schema.chat +CREATE INDEX idx_chat_items_feed_id ON test_chat_schema.chat_items USING btree (feed_id); + + + +CREATE INDEX idx_chat_items_feed_item_contact ON test_chat_schema.chat_items USING btree (feed_item_id, contact_id); + + + +CREATE INDEX idx_chat_items_feed_item_group ON test_chat_schema.chat_items USING btree (feed_item_id, group_id); + + + +CREATE INDEX idx_chat_items_feeds_created_at ON test_chat_schema.chat_items USING btree (user_id, feed_id, created_at); + + + CREATE INDEX idx_chat_items_forwarded_by_group_member_id ON test_chat_schema.chat_items USING btree (forwarded_by_group_member_id); @@ -2648,6 +2732,10 @@ CREATE INDEX idx_contacts_grp_direct_inv_from_member_conn_id ON test_chat_schema +CREATE INDEX idx_contacts_user_id ON test_chat_schema.contacts USING btree (user_id, contact_id); + + + CREATE INDEX idx_contacts_xcontact_id ON test_chat_schema.contacts USING btree (xcontact_id); @@ -2708,6 +2796,18 @@ CREATE INDEX idx_extra_xftp_file_descriptions_user_id ON test_chat_schema.extra_ +CREATE INDEX idx_feed_jobs_chat_item_id ON test_chat_schema.feed_jobs USING btree (chat_item_id, action_tag); + + + +CREATE INDEX idx_feed_jobs_next ON test_chat_schema.feed_jobs USING btree (feed_id, worker_scope, failed, job_status, feed_job_id); + + + +CREATE INDEX idx_feeds_user_id ON test_chat_schema.feeds USING btree (user_id); + + + CREATE UNIQUE INDEX idx_file_badge_proofs_file_id_kind ON test_chat_schema.file_badge_proofs USING btree (file_id, proof_kind); @@ -2720,6 +2820,10 @@ CREATE INDEX idx_files_contact_id ON test_chat_schema.files USING btree (contact +CREATE INDEX idx_files_feed_id ON test_chat_schema.files USING btree (feed_id); + + + CREATE INDEX idx_files_group_id ON test_chat_schema.files USING btree (group_id); @@ -2844,6 +2948,10 @@ CREATE INDEX idx_groups_summary_current_members_count ON test_chat_schema.groups +CREATE INDEX idx_groups_user_id_business_chat ON test_chat_schema.groups USING btree (user_id, business_chat, group_id); + + + CREATE INDEX idx_groups_via_group_link_uri_hash ON test_chat_schema.groups USING btree (user_id, via_group_link_uri_hash); @@ -2860,6 +2968,10 @@ CREATE INDEX idx_messages_created_at ON test_chat_schema.messages USING btree (c +CREATE INDEX idx_messages_feed_id ON test_chat_schema.messages USING btree (feed_id); + + + CREATE INDEX idx_messages_forwarded_by_group_member_id ON test_chat_schema.messages USING btree (forwarded_by_group_member_id); @@ -3182,6 +3294,16 @@ ALTER TABLE ONLY test_chat_schema.chat_items +ALTER TABLE ONLY test_chat_schema.chat_items + ADD CONSTRAINT chat_items_feed_id_fkey FOREIGN KEY (feed_id) REFERENCES test_chat_schema.feeds(feed_id) ON DELETE CASCADE; + + + +ALTER TABLE ONLY test_chat_schema.chat_items + ADD CONSTRAINT chat_items_feed_item_id_fkey FOREIGN KEY (feed_item_id) REFERENCES test_chat_schema.chat_items(chat_item_id) ON DELETE SET NULL; + + + ALTER TABLE ONLY test_chat_schema.chat_items ADD CONSTRAINT chat_items_forwarded_by_group_member_id_fkey FOREIGN KEY (forwarded_by_group_member_id) REFERENCES test_chat_schema.group_members(group_member_id) ON DELETE SET NULL; @@ -3417,6 +3539,21 @@ ALTER TABLE ONLY test_chat_schema.extra_xftp_file_descriptions +ALTER TABLE ONLY test_chat_schema.feed_jobs + ADD CONSTRAINT feed_jobs_chat_item_id_fkey FOREIGN KEY (chat_item_id) REFERENCES test_chat_schema.chat_items(chat_item_id) ON DELETE CASCADE; + + + +ALTER TABLE ONLY test_chat_schema.feed_jobs + ADD CONSTRAINT feed_jobs_feed_id_fkey FOREIGN KEY (feed_id) REFERENCES test_chat_schema.feeds(feed_id) ON DELETE CASCADE; + + + +ALTER TABLE ONLY test_chat_schema.feeds + ADD CONSTRAINT feeds_user_id_fkey FOREIGN KEY (user_id) REFERENCES test_chat_schema.users(user_id) ON DELETE CASCADE; + + + ALTER TABLE ONLY test_chat_schema.file_badge_proofs ADD CONSTRAINT file_badge_proofs_file_id_fkey FOREIGN KEY (file_id) REFERENCES test_chat_schema.files(file_id) ON DELETE CASCADE; @@ -3427,6 +3564,11 @@ ALTER TABLE ONLY test_chat_schema.files +ALTER TABLE ONLY test_chat_schema.files + ADD CONSTRAINT files_feed_id_fkey FOREIGN KEY (feed_id) REFERENCES test_chat_schema.feeds(feed_id) ON DELETE CASCADE; + + + ALTER TABLE ONLY test_chat_schema.files ADD CONSTRAINT files_group_id_fkey FOREIGN KEY (group_id) REFERENCES test_chat_schema.groups(group_id) ON DELETE CASCADE; @@ -3622,6 +3764,11 @@ ALTER TABLE ONLY test_chat_schema.messages +ALTER TABLE ONLY test_chat_schema.messages + ADD CONSTRAINT messages_feed_id_fkey FOREIGN KEY (feed_id) REFERENCES test_chat_schema.feeds(feed_id) ON DELETE CASCADE; + + + ALTER TABLE ONLY test_chat_schema.messages ADD CONSTRAINT messages_forwarded_by_group_member_id_fkey FOREIGN KEY (forwarded_by_group_member_id) REFERENCES test_chat_schema.group_members(group_member_id) ON DELETE SET NULL; 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 a70bf5e47d..30073c93a7 100644 --- a/src/Simplex/Chat/Store/SQLite/Migrations/agent_query_plans.txt +++ b/src/Simplex/Chat/Store/SQLite/Migrations/agent_query_plans.txt @@ -1371,6 +1371,10 @@ Query: SELECT 1 FROM snd_message_deliveries WHERE conn_id = ? AND failed = 0 LIM Plan: SEARCH snd_message_deliveries USING COVERING INDEX idx_snd_message_deliveries_expired (conn_id=?) +Query: SELECT 1 FROM snd_queues WHERE host = ? AND port = ? AND snd_id = ? AND status != ? LIMIT 1 +Plan: +SEARCH snd_queues USING PRIMARY KEY (host=? AND port=? AND snd_id=?) + Query: SELECT conn_id FROM connections WHERE deleted = 0 Plan: SEARCH connections USING COVERING INDEX idx_connections_deleted (deleted=?) 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 1da3b2af85..a0ddf81e67 100644 --- a/src/Simplex/Chat/Store/SQLite/Migrations/chat_query_plans.txt +++ b/src/Simplex/Chat/Store/SQLite/Migrations/chat_query_plans.txt @@ -139,7 +139,7 @@ Plan: Query: SELECT -- Contact - ct.contact_id, ct.contact_profile_id, ct.local_display_name, cp.display_name, cp.full_name, cp.short_descr, cp.description, cp.image, cp.contact_link, cp.chat_peer_type, cp.local_alias, ct.contact_used, ct.contact_status, ct.enable_ntfs, ct.send_rcpts, ct.favorite, + ct.contact_id, ct.contact_profile_id, ct.local_display_name, cp.display_name, cp.full_name, cp.short_descr, cp.description, cp.image, cp.contact_link, cp.chat_peer_type, cp.local_alias, ct.contact_used, ct.contact_status, ct.enable_ntfs, ct.send_rcpts, ct.favorite, ct.drop_feed, cp.preferences, cp.preferences_json, ct.user_preferences, ct.created_at, ct.updated_at, ct.chat_ts, ct.conn_full_link_to_connect, ct.conn_short_link_to_connect, ct.welcome_shared_msg_id, ct.request_shared_msg_id, ct.contact_request_id, cr2.rejection_supported, ct.contact_group_member_id, ct.contact_grp_inv_sent, ct.grp_direct_inv_link, ct.grp_direct_inv_from_group_id, ct.grp_direct_inv_from_group_member_id, ct.grp_direct_inv_from_member_conn_id, ct.grp_direct_inv_started_connection, ct.ui_themes, ct.chat_deleted, ct.custom_data, ct.chat_item_ttl, ct.chat_layout, @@ -155,7 +155,7 @@ Query: WHERE ct.user_id = ? AND ct.xcontact_id = ? AND ct.deleted = 0 Plan: -SEARCH ct USING INDEX idx_contacts_chat_ts (user_id=?) +SEARCH ct USING INDEX idx_contacts_user_id (user_id=?) SEARCH cp USING INTEGER PRIMARY KEY (rowid=?) SEARCH c USING INDEX idx_connections_contact_id (contact_id=?) LEFT-JOIN SEARCH cr2 USING INTEGER PRIMARY KEY (rowid=?) LEFT-JOIN @@ -165,7 +165,7 @@ Query: -- GroupInfo g.group_id, g.local_display_name, gp.display_name, gp.full_name, gp.short_descr, g.local_alias, gp.description, gp.image, gp.group_type, gp.group_link, gp.public_group_id, gp.group_web_page, gp.group_domain, gp.domain_web_page, gp.allow_embedding, gp.group_domain_proof, - g.enable_ntfs, g.send_rcpts, g.favorite, gp.preferences, gp.preferences_json, gp.member_admission, gp.chat_layout, + g.enable_ntfs, g.send_rcpts, g.favorite, g.drop_feed, gp.preferences, gp.preferences_json, gp.member_admission, gp.chat_layout, g.created_at, g.updated_at, g.chat_ts, g.user_member_profile_sent_at, g.conn_full_link_to_connect, g.conn_short_link_to_connect, g.conn_link_prepared_connection, g.conn_link_started_connection, g.welcome_shared_msg_id, g.request_shared_msg_id, g.business_chat, g.business_member_id, g.customer_member_id, @@ -759,15 +759,15 @@ SEARCH contacts USING COVERING INDEX idx_contacts_contact_group_member_id (conta Query: INSERT INTO messages ( - msg_sent, chat_msg_event, msg_body, msg_chat_binding, msg_signatures, connection_id, group_id, + msg_sent, chat_msg_event, msg_body, msg_chat_binding, msg_signatures, connection_id, group_id, feed_id, shared_msg_id, shared_msg_id_user, created_at, updated_at - ) VALUES (?,?,?,?,?,?,?,?,?,?,?) + ) VALUES (?,?,?,?,?,?,?,?,?,?,?,?) Plan: Query: SELECT - c.contact_profile_id, c.local_display_name, p.display_name, p.full_name, p.short_descr, p.description, p.image, p.contact_link, p.chat_peer_type, p.local_alias, c.contact_used, c.contact_status, c.enable_ntfs, c.send_rcpts, c.favorite, + c.contact_profile_id, c.local_display_name, p.display_name, p.full_name, p.short_descr, p.description, p.image, p.contact_link, p.chat_peer_type, p.local_alias, c.contact_used, c.contact_status, c.enable_ntfs, c.send_rcpts, c.favorite, c.drop_feed, p.preferences, p.preferences_json, c.user_preferences, c.created_at, c.updated_at, c.chat_ts, c.conn_full_link_to_connect, c.conn_short_link_to_connect, c.welcome_shared_msg_id, c.request_shared_msg_id, c.contact_request_id, cr2.rejection_supported, c.contact_group_member_id, c.contact_grp_inv_sent, c.grp_direct_inv_link, c.grp_direct_inv_from_group_id, c.grp_direct_inv_from_group_member_id, c.grp_direct_inv_from_member_conn_id, c.grp_direct_inv_started_connection, c.ui_themes, c.chat_deleted, c.custom_data, c.chat_item_ttl, c.chat_layout, @@ -972,7 +972,7 @@ Plan: SEARCH chat_items USING INDEX idx_chat_items_groups_item_ts (user_id=? AND group_id=?) Query: - SELECT chat_item_id, contact_id, group_id, group_scope_tag, group_scope_group_member_id, note_folder_id + SELECT chat_item_id, contact_id, group_id, group_scope_tag, group_scope_group_member_id, note_folder_id, feed_id FROM chat_items WHERE user_id = ? AND LOWER(item_text) LIKE '%' || LOWER(?) || '%' AND (item_ts < ? OR (item_ts = ? AND chat_item_id < ?)) @@ -980,18 +980,18 @@ Query: LIMIT ? Plan: -SEARCH chat_items USING INDEX idx_chat_items_groups_item_viewed (user_id=?) +SEARCH chat_items USING INDEX idx_chat_items_feeds_created_at (user_id=?) USE TEMP B-TREE FOR ORDER BY Query: - SELECT chat_item_id, contact_id, group_id, group_scope_tag, group_scope_group_member_id, note_folder_id + SELECT chat_item_id, contact_id, group_id, group_scope_tag, group_scope_group_member_id, note_folder_id, feed_id FROM chat_items WHERE user_id = ? 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_groups_item_viewed (user_id=?) +SEARCH chat_items USING INDEX idx_chat_items_feeds_created_at (user_id=?) USE TEMP B-TREE FOR ORDER BY Query: @@ -1070,6 +1070,25 @@ Query: Plan: SEARCH delivery_tasks USING COVERING INDEX idx_delivery_tasks_next (group_id=? AND worker_scope=? AND failed=? AND task_status=?) +Query: + SELECT feed_job_id + FROM feed_jobs + WHERE feed_id = ? AND worker_scope = ? + AND failed = 0 AND job_status = ? + ORDER BY feed_job_id ASC + LIMIT 1 + +Plan: +SEARCH feed_jobs USING COVERING INDEX idx_feed_jobs_next (feed_id=? AND worker_scope=? AND failed=? AND job_status=?) + +Query: + SELECT feed_job_id, chat_item_id, action_tag, message_ids, cursor_id + FROM feed_jobs + WHERE feed_job_id = ? + +Plan: +SEARCH feed_jobs USING INTEGER PRIMARY KEY (rowid=?) + Query: SELECT group_id FROM groups @@ -1107,7 +1126,7 @@ SEARCH p USING INTEGER PRIMARY KEY (rowid=?) SEARCH i USING COVERING INDEX idx_chat_items_group_shared_msg_id (user_id=? AND group_id=? AND group_member_id=? AND shared_msg_id=?) LEFT-JOIN Query: - SELECT i.chat_item_id, i.contact_id, i.group_id, i.group_scope_tag, i.group_scope_group_member_id, i.note_folder_id + SELECT i.chat_item_id, i.contact_id, i.group_id, i.group_scope_tag, i.group_scope_group_member_id, i.note_folder_id, i.feed_id FROM chat_items i JOIN files f ON f.chat_item_id = i.chat_item_id WHERE f.user_id = ? AND f.file_id = ? @@ -1141,6 +1160,16 @@ Query: Plan: SEARCH display_names USING COVERING INDEX sqlite_autoindex_display_names_2 (user_id=? AND ldn_base=?) +Query: + SELECT p.display_name, m.member_status + FROM group_members m + JOIN contact_profiles p ON p.contact_profile_id = COALESCE(m.member_profile_id, m.contact_profile_id) + WHERE m.member_category = 'user' + +Plan: +SCAN m +SEARCH p USING INTEGER PRIMARY KEY (rowid=?) + Query: SELECT s.contact_id, g.group_id, s.group_member_id FROM sent_probes s @@ -1436,7 +1465,25 @@ Query: i.item_deleted, i.item_deleted_ts, i.item_edited, i.created_at, i.updated_at, i.fwd_from_tag, i.fwd_from_chat_name, i.fwd_from_msg_dir, i.fwd_from_contact_id, i.fwd_from_group_id, i.fwd_from_chat_item_id, i.fwd_from_group_type, i.fwd_from_group_link, i.fwd_from_public_group_id, i.fwd_from_member_id, i.fwd_from_shared_msg_id, - i.timed_ttl, i.timed_delete_at, i.item_live, i.user_mention, i.has_link, i.msg_signed, + i.timed_ttl, i.timed_delete_at, i.item_live, i.user_mention, i.has_link, i.msg_signed, i.item_feed, + -- CIFile + f.file_id, f.file_name, f.file_size, f.file_path, f.file_crypto_key, f.file_crypto_nonce, f.ci_file_status, f.protocol, f.file_expires_at, f.file_max_size, f.file_badge_status + FROM chat_items i + LEFT JOIN files f ON f.chat_item_id = i.chat_item_id + WHERE i.user_id = ? AND i.feed_id = ? AND i.chat_item_id = ? + +Plan: +SEARCH i USING INTEGER PRIMARY KEY (rowid=?) +SEARCH f USING INDEX idx_files_chat_item_id (chat_item_id=?) LEFT-JOIN + +Query: + SELECT + -- ChatItem + i.chat_item_id, i.item_ts, i.item_sent, i.item_content, i.item_text, i.item_status, i.via_proxy, i.shared_msg_id, + i.item_deleted, i.item_deleted_ts, i.item_edited, i.created_at, i.updated_at, + i.fwd_from_tag, i.fwd_from_chat_name, i.fwd_from_msg_dir, i.fwd_from_contact_id, i.fwd_from_group_id, i.fwd_from_chat_item_id, + i.fwd_from_group_type, i.fwd_from_group_link, i.fwd_from_public_group_id, i.fwd_from_member_id, i.fwd_from_shared_msg_id, + i.timed_ttl, i.timed_delete_at, i.item_live, i.user_mention, i.has_link, i.msg_signed, i.item_feed, -- CIFile f.file_id, f.file_name, f.file_size, f.file_path, f.file_crypto_key, f.file_crypto_nonce, f.ci_file_status, f.protocol, f.file_expires_at, f.file_max_size, f.file_badge_status FROM chat_items i @@ -1454,7 +1501,7 @@ Query: i.item_deleted, i.item_deleted_ts, i.item_edited, i.created_at, i.updated_at, i.fwd_from_tag, i.fwd_from_chat_name, i.fwd_from_msg_dir, i.fwd_from_contact_id, i.fwd_from_group_id, i.fwd_from_chat_item_id, i.fwd_from_group_type, i.fwd_from_group_link, i.fwd_from_public_group_id, i.fwd_from_member_id, i.fwd_from_shared_msg_id, - i.timed_ttl, i.timed_delete_at, i.item_live, i.user_mention, i.has_link, i.msg_signed, + i.timed_ttl, i.timed_delete_at, i.item_live, i.user_mention, i.has_link, i.msg_signed, i.item_feed, -- CIFile f.file_id, f.file_name, f.file_size, f.file_path, f.file_crypto_key, f.file_crypto_nonce, f.ci_file_status, f.protocol, f.file_expires_at, f.file_max_size, f.file_badge_status, -- CIMeta forwardedByMember, showGroupAsSender @@ -1483,7 +1530,7 @@ Query: dbm.created_at, dbm.updated_at, dbm.support_chat_ts, dbm.support_chat_items_unread, dbm.support_chat_items_member_attention, dbm.support_chat_items_mentions, dbm.support_chat_last_msg_from_member_ts, dbm.member_pub_key, dbm.relay_link, dbm.member_security_code, dbm.member_security_code_verified_at FROM chat_items i - LEFT JOIN files f ON f.chat_item_id = i.chat_item_id + LEFT JOIN files f ON f.chat_item_id = COALESCE(i.feed_item_id, i.chat_item_id) LEFT JOIN group_members m ON m.group_member_id = i.group_member_id LEFT JOIN contact_profiles p ON p.contact_profile_id = COALESCE(m.member_profile_id, m.contact_profile_id) LEFT JOIN chat_items ri ON ri.shared_msg_id = i.quoted_shared_msg_id AND ri.group_id = i.group_id @@ -1511,13 +1558,13 @@ Query: i.item_deleted, i.item_deleted_ts, i.item_edited, i.created_at, i.updated_at, i.fwd_from_tag, i.fwd_from_chat_name, i.fwd_from_msg_dir, i.fwd_from_contact_id, i.fwd_from_group_id, i.fwd_from_chat_item_id, i.fwd_from_group_type, i.fwd_from_group_link, i.fwd_from_public_group_id, i.fwd_from_member_id, i.fwd_from_shared_msg_id, - i.timed_ttl, i.timed_delete_at, i.item_live, i.user_mention, i.has_link, i.msg_signed, + i.timed_ttl, i.timed_delete_at, i.item_live, i.user_mention, i.has_link, i.msg_signed, i.item_feed, -- CIFile f.file_id, f.file_name, f.file_size, f.file_path, f.file_crypto_key, f.file_crypto_nonce, f.ci_file_status, f.protocol, f.file_expires_at, f.file_max_size, f.file_badge_status, -- DirectQuote ri.chat_item_id, i.quoted_shared_msg_id, i.quoted_sent_at, i.quoted_content, i.quoted_sent FROM chat_items i - LEFT JOIN files f ON f.chat_item_id = i.chat_item_id + LEFT JOIN files f ON f.chat_item_id = COALESCE(i.feed_item_id, i.chat_item_id) LEFT JOIN chat_items ri ON ri.user_id = i.user_id AND ri.contact_id = i.contact_id AND ri.shared_msg_id = i.quoted_shared_msg_id WHERE i.user_id = ? AND i.contact_id = ? AND i.chat_item_id = ? @@ -1529,7 +1576,7 @@ SEARCH ri USING COVERING INDEX idx_chat_items_direct_shared_msg_id (user_id=? AN Query: SELECT -- Contact - ct.contact_id, ct.contact_profile_id, ct.local_display_name, cp.display_name, cp.full_name, cp.short_descr, cp.description, cp.image, cp.contact_link, cp.chat_peer_type, cp.local_alias, ct.contact_used, ct.contact_status, ct.enable_ntfs, ct.send_rcpts, ct.favorite, + ct.contact_id, ct.contact_profile_id, ct.local_display_name, cp.display_name, cp.full_name, cp.short_descr, cp.description, cp.image, cp.contact_link, cp.chat_peer_type, cp.local_alias, ct.contact_used, ct.contact_status, ct.enable_ntfs, ct.send_rcpts, ct.favorite, ct.drop_feed, cp.preferences, cp.preferences_json, ct.user_preferences, ct.created_at, ct.updated_at, ct.chat_ts, ct.conn_full_link_to_connect, ct.conn_short_link_to_connect, ct.welcome_shared_msg_id, ct.request_shared_msg_id, ct.contact_request_id, cr2.rejection_supported, ct.contact_group_member_id, ct.contact_grp_inv_sent, ct.grp_direct_inv_link, ct.grp_direct_inv_from_group_id, ct.grp_direct_inv_from_group_member_id, ct.grp_direct_inv_from_member_conn_id, ct.grp_direct_inv_started_connection, ct.ui_themes, ct.chat_deleted, ct.custom_data, ct.chat_item_ttl, ct.chat_layout, @@ -1571,6 +1618,14 @@ SEARCH users USING INTEGER PRIMARY KEY (rowid=?) INDEX 2 SEARCH users USING INDEX sqlite_autoindex_users_1 (contact_id=?) +Query: + SELECT COUNT(1) + FROM feed_jobs + WHERE chat_item_id = ? AND action_tag = ? AND job_status != ? + +Plan: +SEARCH feed_jobs USING INDEX idx_feed_jobs_chat_item_id (chat_item_id=? AND action_tag=?) + Query: SELECT agent_conn_id FROM ( SELECT @@ -1606,7 +1661,7 @@ Query: Plan: SEARCH c USING INDEX idx_connections_contact_id (contact_id=?) -SEARCH ct USING INTEGER PRIMARY KEY (rowid=?) +SEARCH ct USING COVERING INDEX idx_contacts_user_id (user_id=? AND contact_id=? AND rowid=?) Query: SELECT chat_item_id @@ -1629,7 +1684,7 @@ Plan: SEARCH chat_items USING INDEX idx_chat_items_group_id (group_id=?) Query: - SELECT chat_item_id, contact_id, group_id, group_scope_tag, group_scope_group_member_id, note_folder_id + SELECT chat_item_id, contact_id, group_id, group_scope_tag, group_scope_group_member_id, note_folder_id, feed_id FROM chat_items WHERE chat_item_id = ? @@ -1637,7 +1692,7 @@ Plan: SEARCH chat_items USING INTEGER PRIMARY KEY (rowid=?) Query: - SELECT chat_item_id, contact_id, group_id, group_scope_tag, group_scope_group_member_id, note_folder_id + SELECT chat_item_id, contact_id, group_id, group_scope_tag, group_scope_group_member_id, note_folder_id, feed_id FROM chat_items WHERE user_id = ? AND LOWER(item_text) LIKE '%' || LOWER(?) || '%' AND (item_ts > ? OR (item_ts = ? AND chat_item_id > ?)) @@ -1645,7 +1700,7 @@ Query: LIMIT ? Plan: -SEARCH chat_items USING INDEX idx_chat_items_groups_item_viewed (user_id=?) +SEARCH chat_items USING INDEX idx_chat_items_feeds_created_at (user_id=?) USE TEMP B-TREE FOR ORDER BY Query: @@ -1786,7 +1841,7 @@ Plan: SEARCH i USING COVERING INDEX idx_chat_items_groups_history (user_id=? AND group_id=? AND include_in_history=? AND item_deleted=?) Query: - SELECT i.chat_item_id, i.contact_id, i.group_id, i.group_scope_tag, i.group_scope_group_member_id, i.note_folder_id + SELECT i.chat_item_id, i.contact_id, i.group_id, i.group_scope_tag, i.group_scope_group_member_id, i.note_folder_id, i.feed_id FROM chat_items i JOIN groups g ON g.chat_item_id = i.chat_item_id WHERE g.user_id = ? AND g.group_id = ? @@ -2130,7 +2185,7 @@ SEARCH prev USING INDEX idx_badge_ledger_purchase (badge_purchase_id=? AND entry Query: SELECT -- Contact - ct.contact_id, ct.contact_profile_id, ct.local_display_name, cp.display_name, cp.full_name, cp.short_descr, cp.description, cp.image, cp.contact_link, cp.chat_peer_type, cp.local_alias, ct.contact_used, ct.contact_status, ct.enable_ntfs, ct.send_rcpts, ct.favorite, + ct.contact_id, ct.contact_profile_id, ct.local_display_name, cp.display_name, cp.full_name, cp.short_descr, cp.description, cp.image, cp.contact_link, cp.chat_peer_type, cp.local_alias, ct.contact_used, ct.contact_status, ct.enable_ntfs, ct.send_rcpts, ct.favorite, ct.drop_feed, cp.preferences, cp.preferences_json, ct.user_preferences, ct.created_at, ct.updated_at, ct.chat_ts, ct.conn_full_link_to_connect, ct.conn_short_link_to_connect, ct.welcome_shared_msg_id, ct.request_shared_msg_id, ct.contact_request_id, cr2.rejection_supported, ct.contact_group_member_id, ct.contact_grp_inv_sent, ct.grp_direct_inv_link, ct.grp_direct_inv_from_group_id, ct.grp_direct_inv_from_group_member_id, ct.grp_direct_inv_from_member_conn_id, ct.grp_direct_inv_started_connection, ct.ui_themes, ct.chat_deleted, ct.custom_data, ct.chat_item_ttl, ct.chat_layout, @@ -2140,19 +2195,122 @@ Query: c.connection_id, c.agent_conn_id, c.conn_level, c.via_contact, c.via_user_contact_link, c.via_group_link, c.group_link_id, c.xcontact_id, c.custom_user_profile_id, c.conn_status, c.conn_type, c.contact_conn_initiated, c.local_alias, c.contact_id, c.group_member_id, c.user_contact_link_id, c.created_at, c.security_code, c.security_code_verified_at, c.pq_support, c.pq_encryption, c.pq_snd_enabled, c.pq_rcv_enabled, c.auth_err_counter, c.quota_err_counter, c.conn_chat_version, c.peer_chat_min_version, c.peer_chat_max_version + FROM contacts ct JOIN contact_profiles cp ON ct.contact_profile_id = cp.contact_profile_id LEFT JOIN connections c ON c.contact_id = ct.contact_id LEFT JOIN contact_requests cr2 ON cr2.contact_request_id = ct.contact_request_id - WHERE ct.user_id = ? AND ct.contact_id = ? - AND ct.deleted = ? - + WHERE ct.user_id = ? AND ct.contact_id = ? AND ct.deleted = ? Plan: SEARCH ct USING INTEGER PRIMARY KEY (rowid=?) SEARCH cp USING INTEGER PRIMARY KEY (rowid=?) SEARCH c USING INDEX idx_connections_contact_id (contact_id=?) LEFT-JOIN SEARCH cr2 USING INTEGER PRIMARY KEY (rowid=?) LEFT-JOIN +Query: + SELECT + -- Contact + ct.contact_id, ct.contact_profile_id, ct.local_display_name, cp.display_name, cp.full_name, cp.short_descr, cp.description, cp.image, cp.contact_link, cp.chat_peer_type, cp.local_alias, ct.contact_used, ct.contact_status, ct.enable_ntfs, ct.send_rcpts, ct.favorite, ct.drop_feed, + cp.preferences, cp.preferences_json, ct.user_preferences, ct.created_at, ct.updated_at, ct.chat_ts, ct.conn_full_link_to_connect, ct.conn_short_link_to_connect, ct.welcome_shared_msg_id, ct.request_shared_msg_id, ct.contact_request_id, cr2.rejection_supported, + ct.contact_group_member_id, ct.contact_grp_inv_sent, ct.grp_direct_inv_link, ct.grp_direct_inv_from_group_id, ct.grp_direct_inv_from_group_member_id, ct.grp_direct_inv_from_member_conn_id, ct.grp_direct_inv_started_connection, + ct.ui_themes, ct.chat_deleted, ct.custom_data, ct.chat_item_ttl, ct.chat_layout, + cp.badge_proof, cp.badge_pres_header, cp.badge_expiry, cp.badge_type, cp.badge_verified, cp.badge_extra, cp.badge_master_key, cp.badge_signature, cp.badge_key_idx, + cp.contact_domain, cp.contact_domain_proof, cp.contact_domain_verified, + -- Connection + c.connection_id, c.agent_conn_id, c.conn_level, c.via_contact, c.via_user_contact_link, c.via_group_link, c.group_link_id, c.xcontact_id, c.custom_user_profile_id, c.conn_status, c.conn_type, c.contact_conn_initiated, c.local_alias, + c.contact_id, c.group_member_id, c.user_contact_link_id, c.created_at, c.security_code, c.security_code_verified_at, c.pq_support, c.pq_encryption, c.pq_snd_enabled, c.pq_rcv_enabled, c.auth_err_counter, c.quota_err_counter, + c.conn_chat_version, c.peer_chat_min_version, c.peer_chat_max_version + , i.chat_item_id + FROM contacts ct + JOIN contact_profiles cp ON ct.contact_profile_id = cp.contact_profile_id + LEFT JOIN connections c ON c.contact_id = ct.contact_id + LEFT JOIN contact_requests cr2 ON cr2.contact_request_id = ct.contact_request_id + JOIN chat_items i ON i.contact_id = ct.contact_id WHERE i.user_id = ? AND i.feed_item_id = ? AND i.contact_id > ? AND i.item_deleted = 0 ORDER BY i.contact_id ASC LIMIT ? +Plan: +SEARCH i USING INDEX idx_chat_items_feed_item_contact (feed_item_id=? AND contact_id>?) +SEARCH ct USING INTEGER PRIMARY KEY (rowid=?) +SEARCH cp USING INTEGER PRIMARY KEY (rowid=?) +SEARCH c USING INDEX idx_connections_contact_id (contact_id=?) LEFT-JOIN +SEARCH cr2 USING INTEGER PRIMARY KEY (rowid=?) LEFT-JOIN + +Query: + SELECT + -- Contact + ct.contact_id, ct.contact_profile_id, ct.local_display_name, cp.display_name, cp.full_name, cp.short_descr, cp.description, cp.image, cp.contact_link, cp.chat_peer_type, cp.local_alias, ct.contact_used, ct.contact_status, ct.enable_ntfs, ct.send_rcpts, ct.favorite, ct.drop_feed, + cp.preferences, cp.preferences_json, ct.user_preferences, ct.created_at, ct.updated_at, ct.chat_ts, ct.conn_full_link_to_connect, ct.conn_short_link_to_connect, ct.welcome_shared_msg_id, ct.request_shared_msg_id, ct.contact_request_id, cr2.rejection_supported, + ct.contact_group_member_id, ct.contact_grp_inv_sent, ct.grp_direct_inv_link, ct.grp_direct_inv_from_group_id, ct.grp_direct_inv_from_group_member_id, ct.grp_direct_inv_from_member_conn_id, ct.grp_direct_inv_started_connection, + ct.ui_themes, ct.chat_deleted, ct.custom_data, ct.chat_item_ttl, ct.chat_layout, + cp.badge_proof, cp.badge_pres_header, cp.badge_expiry, cp.badge_type, cp.badge_verified, cp.badge_extra, cp.badge_master_key, cp.badge_signature, cp.badge_key_idx, + cp.contact_domain, cp.contact_domain_proof, cp.contact_domain_verified, + -- Connection + c.connection_id, c.agent_conn_id, c.conn_level, c.via_contact, c.via_user_contact_link, c.via_group_link, c.group_link_id, c.xcontact_id, c.custom_user_profile_id, c.conn_status, c.conn_type, c.contact_conn_initiated, c.local_alias, + c.contact_id, c.group_member_id, c.user_contact_link_id, c.created_at, c.security_code, c.security_code_verified_at, c.pq_support, c.pq_encryption, c.pq_snd_enabled, c.pq_rcv_enabled, c.auth_err_counter, c.quota_err_counter, + c.conn_chat_version, c.peer_chat_min_version, c.peer_chat_max_version + , i.chat_item_id + FROM contacts ct + JOIN contact_profiles cp ON ct.contact_profile_id = cp.contact_profile_id + LEFT JOIN connections c ON c.contact_id = ct.contact_id + LEFT JOIN contact_requests cr2 ON cr2.contact_request_id = ct.contact_request_id + JOIN chat_items i ON i.contact_id = ct.contact_id WHERE i.user_id = ? AND i.feed_item_id = ? AND i.contact_id > ? AND i.item_feed = 1 ORDER BY i.contact_id ASC LIMIT ? +Plan: +SEARCH i USING INDEX idx_chat_items_feed_item_contact (feed_item_id=? AND contact_id>?) +SEARCH ct USING INTEGER PRIMARY KEY (rowid=?) +SEARCH cp USING INTEGER PRIMARY KEY (rowid=?) +SEARCH c USING INDEX idx_connections_contact_id (contact_id=?) LEFT-JOIN +SEARCH cr2 USING INTEGER PRIMARY KEY (rowid=?) LEFT-JOIN + +Query: + SELECT + -- Contact + ct.contact_id, ct.contact_profile_id, ct.local_display_name, cp.display_name, cp.full_name, cp.short_descr, cp.description, cp.image, cp.contact_link, cp.chat_peer_type, cp.local_alias, ct.contact_used, ct.contact_status, ct.enable_ntfs, ct.send_rcpts, ct.favorite, ct.drop_feed, + cp.preferences, cp.preferences_json, ct.user_preferences, ct.created_at, ct.updated_at, ct.chat_ts, ct.conn_full_link_to_connect, ct.conn_short_link_to_connect, ct.welcome_shared_msg_id, ct.request_shared_msg_id, ct.contact_request_id, cr2.rejection_supported, + ct.contact_group_member_id, ct.contact_grp_inv_sent, ct.grp_direct_inv_link, ct.grp_direct_inv_from_group_id, ct.grp_direct_inv_from_group_member_id, ct.grp_direct_inv_from_member_conn_id, ct.grp_direct_inv_started_connection, + ct.ui_themes, ct.chat_deleted, ct.custom_data, ct.chat_item_ttl, ct.chat_layout, + cp.badge_proof, cp.badge_pres_header, cp.badge_expiry, cp.badge_type, cp.badge_verified, cp.badge_extra, cp.badge_master_key, cp.badge_signature, cp.badge_key_idx, + cp.contact_domain, cp.contact_domain_proof, cp.contact_domain_verified, + -- Connection + c.connection_id, c.agent_conn_id, c.conn_level, c.via_contact, c.via_user_contact_link, c.via_group_link, c.group_link_id, c.xcontact_id, c.custom_user_profile_id, c.conn_status, c.conn_type, c.contact_conn_initiated, c.local_alias, + c.contact_id, c.group_member_id, c.user_contact_link_id, c.created_at, c.security_code, c.security_code_verified_at, c.pq_support, c.pq_encryption, c.pq_snd_enabled, c.pq_rcv_enabled, c.auth_err_counter, c.quota_err_counter, + c.conn_chat_version, c.peer_chat_min_version, c.peer_chat_max_version + , i.chat_item_id + FROM contacts ct + JOIN contact_profiles cp ON ct.contact_profile_id = cp.contact_profile_id + LEFT JOIN connections c ON c.contact_id = ct.contact_id + LEFT JOIN contact_requests cr2 ON cr2.contact_request_id = ct.contact_request_id + JOIN chat_items i ON i.contact_id = ct.contact_id WHERE i.user_id = ? AND i.feed_item_id = ? AND i.contact_id > ? AND i.item_feed > 0 ORDER BY i.contact_id ASC LIMIT ? +Plan: +SEARCH i USING INDEX idx_chat_items_feed_item_contact (feed_item_id=? AND contact_id>?) +SEARCH ct USING INTEGER PRIMARY KEY (rowid=?) +SEARCH cp USING INTEGER PRIMARY KEY (rowid=?) +SEARCH c USING INDEX idx_connections_contact_id (contact_id=?) LEFT-JOIN +SEARCH cr2 USING INTEGER PRIMARY KEY (rowid=?) LEFT-JOIN + +Query: + SELECT + -- Contact + ct.contact_id, ct.contact_profile_id, ct.local_display_name, cp.display_name, cp.full_name, cp.short_descr, cp.description, cp.image, cp.contact_link, cp.chat_peer_type, cp.local_alias, ct.contact_used, ct.contact_status, ct.enable_ntfs, ct.send_rcpts, ct.favorite, ct.drop_feed, + cp.preferences, cp.preferences_json, ct.user_preferences, ct.created_at, ct.updated_at, ct.chat_ts, ct.conn_full_link_to_connect, ct.conn_short_link_to_connect, ct.welcome_shared_msg_id, ct.request_shared_msg_id, ct.contact_request_id, cr2.rejection_supported, + ct.contact_group_member_id, ct.contact_grp_inv_sent, ct.grp_direct_inv_link, ct.grp_direct_inv_from_group_id, ct.grp_direct_inv_from_group_member_id, ct.grp_direct_inv_from_member_conn_id, ct.grp_direct_inv_started_connection, + ct.ui_themes, ct.chat_deleted, ct.custom_data, ct.chat_item_ttl, ct.chat_layout, + cp.badge_proof, cp.badge_pres_header, cp.badge_expiry, cp.badge_type, cp.badge_verified, cp.badge_extra, cp.badge_master_key, cp.badge_signature, cp.badge_key_idx, + cp.contact_domain, cp.contact_domain_proof, cp.contact_domain_verified, + -- Connection + c.connection_id, c.agent_conn_id, c.conn_level, c.via_contact, c.via_user_contact_link, c.via_group_link, c.group_link_id, c.xcontact_id, c.custom_user_profile_id, c.conn_status, c.conn_type, c.contact_conn_initiated, c.local_alias, + c.contact_id, c.group_member_id, c.user_contact_link_id, c.created_at, c.security_code, c.security_code_verified_at, c.pq_support, c.pq_encryption, c.pq_snd_enabled, c.pq_rcv_enabled, c.auth_err_counter, c.quota_err_counter, + c.conn_chat_version, c.peer_chat_min_version, c.peer_chat_max_version + , i.chat_item_id + FROM contacts ct + JOIN contact_profiles cp ON ct.contact_profile_id = cp.contact_profile_id + LEFT JOIN connections c ON c.contact_id = ct.contact_id + LEFT JOIN contact_requests cr2 ON cr2.contact_request_id = ct.contact_request_id + LEFT JOIN chat_items i ON i.feed_item_id = ? AND i.contact_id = ct.contact_id WHERE ct.user_id = ? AND ct.deleted = 0 AND ct.is_user = 0 AND ct.contact_id > ? ORDER BY ct.contact_id ASC LIMIT ? +Plan: +SEARCH ct USING INDEX idx_contacts_user_id (user_id=? AND contact_id>?) +SEARCH cp USING INTEGER PRIMARY KEY (rowid=?) +SEARCH c USING INDEX idx_connections_contact_id (contact_id=?) LEFT-JOIN +SEARCH cr2 USING INTEGER PRIMARY KEY (rowid=?) LEFT-JOIN +SEARCH i USING COVERING INDEX idx_chat_items_feed_item_contact (feed_item_id=? AND contact_id=?) LEFT-JOIN + Query: SELECT connection_id, agent_conn_id, conn_status, via_contact_uri_hash, via_user_contact_link, group_link_id, @@ -2678,6 +2836,206 @@ SEARCH ChatStats USING AUTOMATIC COVERING INDEX (contact_id=?) LEFT-JOIN CORRELATED SCALAR SUBQUERY 1 SEARCH ci USING COVERING INDEX idx_chat_items_contacts_created_at (user_id=? AND contact_id=?) +Query: + SELECT + f.feed_id, + f.chat_ts, + ( + SELECT chat_item_id + FROM chat_items ci + WHERE ci.user_id = ? AND ci.feed_id = f.feed_id + ORDER BY ci.created_at DESC + LIMIT 1 + ) AS chat_item_id, + 0, 0, f.unread_chat + FROM feeds f + WHERE f.user_id = ? AND (f.favorite = 1 OR f.unread_chat = 1) ORDER BY f.chat_ts DESC LIMIT ? +Plan: +SEARCH f USING INDEX idx_feeds_user_id (user_id=?) +CORRELATED SCALAR SUBQUERY 1 +SEARCH ci USING COVERING INDEX idx_chat_items_feeds_created_at (user_id=? AND feed_id=?) +USE TEMP B-TREE FOR ORDER BY + +Query: + SELECT + f.feed_id, + f.chat_ts, + ( + SELECT chat_item_id + FROM chat_items ci + WHERE ci.user_id = ? AND ci.feed_id = f.feed_id + ORDER BY ci.created_at DESC + LIMIT 1 + ) AS chat_item_id, + 0, 0, f.unread_chat + FROM feeds f + WHERE f.user_id = ? AND f.chat_ts < ? ORDER BY f.chat_ts DESC LIMIT ? +Plan: +SEARCH f USING INDEX idx_feeds_user_id (user_id=?) +CORRELATED SCALAR SUBQUERY 1 +SEARCH ci USING COVERING INDEX idx_chat_items_feeds_created_at (user_id=? AND feed_id=?) +USE TEMP B-TREE FOR ORDER BY + +Query: + SELECT + f.feed_id, + f.chat_ts, + ( + SELECT chat_item_id + FROM chat_items ci + WHERE ci.user_id = ? AND ci.feed_id = f.feed_id + ORDER BY ci.created_at DESC + LIMIT 1 + ) AS chat_item_id, + 0, 0, f.unread_chat + FROM feeds f + WHERE f.user_id = ? AND f.chat_ts > ? ORDER BY f.chat_ts ASC LIMIT ? +Plan: +SEARCH f USING INDEX idx_feeds_user_id (user_id=?) +CORRELATED SCALAR SUBQUERY 1 +SEARCH ci USING COVERING INDEX idx_chat_items_feeds_created_at (user_id=? AND feed_id=?) +USE TEMP B-TREE FOR ORDER BY + +Query: + SELECT + f.feed_id, + f.chat_ts, + ( + SELECT chat_item_id + FROM chat_items ci + WHERE ci.user_id = ? AND ci.feed_id = f.feed_id + ORDER BY ci.created_at DESC + LIMIT 1 + ) AS chat_item_id, + 0, 0, f.unread_chat + FROM feeds f + WHERE f.user_id = ? AND f.favorite = 1 AND f.chat_ts < ? ORDER BY f.chat_ts DESC LIMIT ? +Plan: +SEARCH f USING INDEX idx_feeds_user_id (user_id=?) +CORRELATED SCALAR SUBQUERY 1 +SEARCH ci USING COVERING INDEX idx_chat_items_feeds_created_at (user_id=? AND feed_id=?) +USE TEMP B-TREE FOR ORDER BY + +Query: + SELECT + f.feed_id, + f.chat_ts, + ( + SELECT chat_item_id + FROM chat_items ci + WHERE ci.user_id = ? AND ci.feed_id = f.feed_id + ORDER BY ci.created_at DESC + LIMIT 1 + ) AS chat_item_id, + 0, 0, f.unread_chat + FROM feeds f + WHERE f.user_id = ? AND f.favorite = 1 AND f.chat_ts > ? ORDER BY f.chat_ts ASC LIMIT ? +Plan: +SEARCH f USING INDEX idx_feeds_user_id (user_id=?) +CORRELATED SCALAR SUBQUERY 1 +SEARCH ci USING COVERING INDEX idx_chat_items_feeds_created_at (user_id=? AND feed_id=?) +USE TEMP B-TREE FOR ORDER BY + +Query: + SELECT + f.feed_id, + f.chat_ts, + ( + SELECT chat_item_id + FROM chat_items ci + WHERE ci.user_id = ? AND ci.feed_id = f.feed_id + ORDER BY ci.created_at DESC + LIMIT 1 + ) AS chat_item_id, + 0, 0, f.unread_chat + FROM feeds f + WHERE f.user_id = ? AND f.favorite = 1 ORDER BY f.chat_ts DESC LIMIT ? +Plan: +SEARCH f USING INDEX idx_feeds_user_id (user_id=?) +CORRELATED SCALAR SUBQUERY 1 +SEARCH ci USING COVERING INDEX idx_chat_items_feeds_created_at (user_id=? AND feed_id=?) +USE TEMP B-TREE FOR ORDER BY + +Query: + SELECT + f.feed_id, + f.chat_ts, + ( + SELECT chat_item_id + FROM chat_items ci + WHERE ci.user_id = ? AND ci.feed_id = f.feed_id + ORDER BY ci.created_at DESC + LIMIT 1 + ) AS chat_item_id, + 0, 0, f.unread_chat + FROM feeds f + WHERE f.user_id = ? AND f.unread_chat = 1 AND f.chat_ts < ? ORDER BY f.chat_ts DESC LIMIT ? +Plan: +SEARCH f USING INDEX idx_feeds_user_id (user_id=?) +CORRELATED SCALAR SUBQUERY 1 +SEARCH ci USING COVERING INDEX idx_chat_items_feeds_created_at (user_id=? AND feed_id=?) +USE TEMP B-TREE FOR ORDER BY + +Query: + SELECT + f.feed_id, + f.chat_ts, + ( + SELECT chat_item_id + FROM chat_items ci + WHERE ci.user_id = ? AND ci.feed_id = f.feed_id + ORDER BY ci.created_at DESC + LIMIT 1 + ) AS chat_item_id, + 0, 0, f.unread_chat + FROM feeds f + WHERE f.user_id = ? AND f.unread_chat = 1 AND f.chat_ts > ? ORDER BY f.chat_ts ASC LIMIT ? +Plan: +SEARCH f USING INDEX idx_feeds_user_id (user_id=?) +CORRELATED SCALAR SUBQUERY 1 +SEARCH ci USING COVERING INDEX idx_chat_items_feeds_created_at (user_id=? AND feed_id=?) +USE TEMP B-TREE FOR ORDER BY + +Query: + SELECT + f.feed_id, + f.chat_ts, + ( + SELECT chat_item_id + FROM chat_items ci + WHERE ci.user_id = ? AND ci.feed_id = f.feed_id + ORDER BY ci.created_at DESC + LIMIT 1 + ) AS chat_item_id, + 0, 0, f.unread_chat + FROM feeds f + WHERE f.user_id = ? AND f.unread_chat = 1 ORDER BY f.chat_ts DESC LIMIT ? +Plan: +SEARCH f USING INDEX idx_feeds_user_id (user_id=?) +CORRELATED SCALAR SUBQUERY 1 +SEARCH ci USING COVERING INDEX idx_chat_items_feeds_created_at (user_id=? AND feed_id=?) +USE TEMP B-TREE FOR ORDER BY + +Query: + SELECT + f.feed_id, + f.chat_ts, + ( + SELECT chat_item_id + FROM chat_items ci + WHERE ci.user_id = ? AND ci.feed_id = f.feed_id + ORDER BY ci.created_at DESC + LIMIT 1 + ) AS chat_item_id, + 0, 0, f.unread_chat + FROM feeds f + WHERE f.user_id = ? ORDER BY f.chat_ts DESC LIMIT ? +Plan: +SEARCH f USING INDEX idx_feeds_user_id (user_id=?) +CORRELATED SCALAR SUBQUERY 1 +SEARCH ci USING COVERING INDEX idx_chat_items_feeds_created_at (user_id=? AND feed_id=?) +USE TEMP B-TREE FOR ORDER BY + Query: SELECT g.group_id, @@ -3644,18 +4002,14 @@ SEARCH uc USING INDEX sqlite_autoindex_user_contact_links_1 (user_id=? AND local SEARCH c USING INDEX idx_connections_user_contact_link_id (user_contact_link_id=?) Query: - SELECT chat_item_id - FROM chat_item_messages - WHERE message_id IN ( - SELECT message_id - FROM msg_deliveries - WHERE connection_id = ? AND agent_msg_id = ? - ) + SELECT c.contact_id + FROM msg_deliveries d + JOIN connections c ON c.connection_id = d.connection_id + WHERE d.message_id = ? AND c.contact_id > ? AND c.contact_id <= ? Plan: -SEARCH chat_item_messages USING INDEX sqlite_autoindex_chat_item_messages_1 (message_id=?) -LIST SUBQUERY 1 -SEARCH msg_deliveries USING INDEX idx_msg_deliveries_agent_msg_id (connection_id=? AND agent_msg_id=?) +SEARCH d USING INDEX idx_msg_deliveries_message_id (message_id=?) +SEARCH c USING INTEGER PRIMARY KEY (rowid=?) Query: SELECT chat_item_id @@ -3707,6 +4061,16 @@ Query: Plan: SEARCH chat_items USING COVERING INDEX idx_chat_items_direct_shared_msg_id (user_id=? AND contact_id=? AND shared_msg_id=?) +Query: + SELECT chat_item_id + FROM chat_items + WHERE user_id = ? AND feed_id = ? AND item_text LIKE ? + ORDER BY chat_item_id DESC + LIMIT 1 + +Plan: +SEARCH chat_items USING INDEX idx_chat_items_feed_id (feed_id=?) + Query: SELECT chat_item_id FROM chat_items @@ -3839,6 +4203,14 @@ Query: Plan: SEARCH cp USING INTEGER PRIMARY KEY (rowid=?) +Query: + SELECT created_at, updated_at, chat_ts, favorite, unread_chat + FROM feeds + WHERE user_id = ? AND feed_id = ? + +Plan: +SEARCH feeds USING INTEGER PRIMARY KEY (rowid=?) + Query: SELECT credential FROM badge_issuances WHERE badge_purchase_id = ? @@ -3858,7 +4230,7 @@ Query: AND p.short_descr IS NOT DISTINCT FROM ? AND p.image IS NOT DISTINCT FROM ? Plan: -SEARCH ct USING INDEX idx_contacts_chat_ts (user_id=?) +SEARCH ct USING INDEX idx_contacts_user_id (user_id=?) SEARCH p USING INTEGER PRIMARY KEY (rowid=?) Query: @@ -3867,7 +4239,7 @@ Query: WHERE ct.user_id = ? AND cp.contact_domain = ? AND cp.contact_domain_verified = 1 AND ct.deleted = 0 Plan: -SEARCH ct USING INDEX idx_contacts_chat_ts (user_id=?) +SEARCH ct USING INDEX idx_contacts_user_id (user_id=?) SEARCH cp USING INTEGER PRIMARY KEY (rowid=?) Query: @@ -3934,14 +4306,14 @@ SEARCH f USING COVERING INDEX idx_files_chat_item_id (chat_item_id=?) Query: SELECT f.file_id FROM files f JOIN rcv_files r ON r.file_id = f.file_id - WHERE f.user_id = ? AND f.group_id = ? AND f.shared_msg_id = ? AND f.file_type = ? - AND r.group_member_id = ? + WHERE f.user_id = ? AND f.group_id = ? AND f.shared_msg_id = ? AND f.file_type = ? AND r.group_member_id = ? + Plan: SEARCH f USING INDEX idx_files_group_id_shared_msg_id (group_id=? AND shared_msg_id=?) SEARCH r USING COVERING INDEX idx_rcv_files_group_member_id (group_member_id=? AND rowid=?) Query: - SELECT file_id, contact_id, group_id, note_folder_id + SELECT file_id, contact_id, group_id, note_folder_id, feed_id FROM files WHERE agent_snd_file_id = ? @@ -3973,7 +4345,7 @@ Query: WHERE g.user_id = ? AND gp.group_domain = ? AND g.group_domain_verified = 1 AND g.business_chat IS NOT NULL Plan: -SEARCH g USING INDEX sqlite_autoindex_groups_2 (user_id=?) +SEARCH g USING INDEX idx_groups_user_id_business_chat (user_id=? AND business_chat>?) SEARCH gp USING INTEGER PRIMARY KEY (rowid=?) Query: @@ -3982,7 +4354,7 @@ Query: WHERE g.user_id = ? AND gp.group_domain = ? AND g.group_domain_verified = 1 AND g.business_chat IS NULL Plan: -SEARCH g USING INDEX sqlite_autoindex_groups_2 (user_id=?) +SEARCH g USING INDEX idx_groups_user_id_business_chat (user_id=? AND business_chat=?) SEARCH gp USING INTEGER PRIMARY KEY (rowid=?) Query: @@ -4010,6 +4382,18 @@ SEARCH mu USING INDEX idx_group_members_contact_id (contact_id=?) SEARCH g USING INTEGER PRIMARY KEY (rowid=?) SEARCH gp USING INTEGER PRIMARY KEY (rowid=?) +Query: + SELECT gm.group_member_id + FROM msg_deliveries d + JOIN connections c ON c.connection_id = d.connection_id + JOIN group_members gm ON gm.group_member_id = c.group_member_id + WHERE d.message_id = ? AND gm.group_id > ? AND gm.group_id <= ? + +Plan: +SEARCH d USING INDEX idx_msg_deliveries_message_id (message_id=?) +SEARCH c USING INTEGER PRIMARY KEY (rowid=?) +SEARCH gm USING INTEGER PRIMARY KEY (rowid=?) + Query: SELECT gp.display_name, gp.full_name, gp.short_descr, gp.description, gp.image, gp.group_type, gp.group_link, gp.public_group_id, @@ -4225,6 +4609,23 @@ SEARCH r USING INDEX idx_chat_item_mentions_chat_item_id (chat_item_id=?) SEARCH m USING INDEX sqlite_autoindex_group_members_1 (group_id=? AND member_id=?) LEFT-JOIN SEARCH p USING INTEGER PRIMARY KEY (rowid=?) LEFT-JOIN +Query: + SELECT r.reaction, COUNT(1) + FROM chat_item_reactions r + LEFT JOIN contacts ct ON ct.contact_id = r.contact_id + LEFT JOIN groups g ON g.group_id = r.group_id + LEFT JOIN group_members mu ON mu.group_id = r.group_id AND mu.member_category = ? + WHERE r.shared_msg_id = ? AND r.reaction_sent = 0 + AND ((r.group_id IS NULL AND ct.user_id = ?) OR (g.user_id = ? AND r.item_member_id = mu.member_id)) + GROUP BY r.reaction + +Plan: +SEARCH r USING INDEX idx_chat_item_reactions_shared_msg_id (shared_msg_id=?) +SEARCH ct USING INTEGER PRIMARY KEY (rowid=?) LEFT-JOIN +SEARCH g USING INTEGER PRIMARY KEY (rowid=?) LEFT-JOIN +SEARCH mu USING INDEX idx_group_members_group_id_index_in_group (group_id=?) LEFT-JOIN +USE TEMP B-TREE FOR GROUP BY + Query: SELECT reaction FROM chat_item_reactions @@ -4262,7 +4663,7 @@ SEARCH chat_item_reactions USING INDEX idx_chat_item_reactions_group (group_id=? USE TEMP B-TREE FOR GROUP BY Query: - SELECT rf.file_id, f.contact_id, f.group_id, f.note_folder_id + SELECT rf.file_id, f.contact_id, f.group_id, f.note_folder_id, f.feed_id FROM rcv_files rf JOIN files f ON f.file_id = rf.file_id WHERE rf.agent_rcv_file_id = ? @@ -4573,11 +4974,13 @@ Query: Plan: SEARCH chat_items USING COVERING INDEX idx_chat_items_group_scope_group_member_id (group_scope_group_member_id=?) +SEARCH feed_jobs USING COVERING INDEX idx_feed_jobs_chat_item_id (chat_item_id=?) SEARCH chat_item_mentions USING COVERING INDEX idx_chat_item_mentions_chat_item_id (chat_item_id=?) SEARCH group_snd_item_statuses USING COVERING INDEX idx_group_snd_item_statuses_chat_item_id (chat_item_id=?) SEARCH chat_item_versions USING COVERING INDEX idx_chat_item_versions_chat_item_id (chat_item_id=?) SEARCH calls USING COVERING INDEX idx_calls_chat_item_id (chat_item_id=?) SEARCH chat_item_messages USING COVERING INDEX sqlite_autoindex_chat_item_messages_2 (chat_item_id=?) +SEARCH chat_items USING COVERING INDEX idx_chat_items_feed_item_group (feed_item_id=?) SEARCH chat_items USING COVERING INDEX idx_chat_items_fwd_from_chat_item_id (fwd_from_chat_item_id=?) SEARCH files USING COVERING INDEX idx_files_chat_item_id (chat_item_id=?) SEARCH groups USING COVERING INDEX idx_groups_chat_item_id (chat_item_id=?) @@ -4588,11 +4991,13 @@ Query: Plan: SEARCH chat_items USING INTEGER PRIMARY KEY (rowid=?) +SEARCH feed_jobs USING COVERING INDEX idx_feed_jobs_chat_item_id (chat_item_id=?) SEARCH chat_item_mentions USING COVERING INDEX idx_chat_item_mentions_chat_item_id (chat_item_id=?) SEARCH group_snd_item_statuses USING COVERING INDEX idx_group_snd_item_statuses_chat_item_id (chat_item_id=?) SEARCH chat_item_versions USING COVERING INDEX idx_chat_item_versions_chat_item_id (chat_item_id=?) SEARCH calls USING COVERING INDEX idx_calls_chat_item_id (chat_item_id=?) SEARCH chat_item_messages USING COVERING INDEX sqlite_autoindex_chat_item_messages_2 (chat_item_id=?) +SEARCH chat_items USING COVERING INDEX idx_chat_items_feed_item_group (feed_item_id=?) SEARCH chat_items USING COVERING INDEX idx_chat_items_fwd_from_chat_item_id (fwd_from_chat_item_id=?) SEARCH files USING COVERING INDEX idx_files_chat_item_id (chat_item_id=?) SEARCH groups USING COVERING INDEX idx_groups_chat_item_id (chat_item_id=?) @@ -4603,11 +5008,13 @@ Query: Plan: SEARCH chat_items USING INTEGER PRIMARY KEY (rowid=?) +SEARCH feed_jobs USING COVERING INDEX idx_feed_jobs_chat_item_id (chat_item_id=?) SEARCH chat_item_mentions USING COVERING INDEX idx_chat_item_mentions_chat_item_id (chat_item_id=?) SEARCH group_snd_item_statuses USING COVERING INDEX idx_group_snd_item_statuses_chat_item_id (chat_item_id=?) SEARCH chat_item_versions USING COVERING INDEX idx_chat_item_versions_chat_item_id (chat_item_id=?) SEARCH calls USING COVERING INDEX idx_calls_chat_item_id (chat_item_id=?) SEARCH chat_item_messages USING COVERING INDEX sqlite_autoindex_chat_item_messages_2 (chat_item_id=?) +SEARCH chat_items USING COVERING INDEX idx_chat_items_feed_item_group (feed_item_id=?) SEARCH chat_items USING COVERING INDEX idx_chat_items_fwd_from_chat_item_id (fwd_from_chat_item_id=?) SEARCH files USING COVERING INDEX idx_files_chat_item_id (chat_item_id=?) SEARCH groups USING COVERING INDEX idx_groups_chat_item_id (chat_item_id=?) @@ -4618,11 +5025,13 @@ Query: Plan: SEARCH chat_items USING INTEGER PRIMARY KEY (rowid=?) +SEARCH feed_jobs USING COVERING INDEX idx_feed_jobs_chat_item_id (chat_item_id=?) SEARCH chat_item_mentions USING COVERING INDEX idx_chat_item_mentions_chat_item_id (chat_item_id=?) SEARCH group_snd_item_statuses USING COVERING INDEX idx_group_snd_item_statuses_chat_item_id (chat_item_id=?) SEARCH chat_item_versions USING COVERING INDEX idx_chat_item_versions_chat_item_id (chat_item_id=?) SEARCH calls USING COVERING INDEX idx_calls_chat_item_id (chat_item_id=?) SEARCH chat_item_messages USING COVERING INDEX sqlite_autoindex_chat_item_messages_2 (chat_item_id=?) +SEARCH chat_items USING COVERING INDEX idx_chat_items_feed_item_group (feed_item_id=?) SEARCH chat_items USING COVERING INDEX idx_chat_items_fwd_from_chat_item_id (fwd_from_chat_item_id=?) SEARCH files USING COVERING INDEX idx_files_chat_item_id (chat_item_id=?) SEARCH groups USING COVERING INDEX idx_groups_chat_item_id (chat_item_id=?) @@ -5081,16 +5490,18 @@ Plan: Query: INSERT INTO chat_items ( -- user and IDs - user_id, created_by_msg_id, contact_id, group_id, group_member_id, note_folder_id, group_scope_tag, group_scope_group_member_id, + user_id, created_by_msg_id, contact_id, group_id, group_member_id, note_folder_id, feed_id, group_scope_tag, group_scope_group_member_id, -- meta item_sent, item_ts, item_content, item_content_tag, item_text, item_status, msg_content_tag, shared_msg_id, forwarded_by_group_member_id, include_in_history, created_at, updated_at, item_live, user_mention, has_link, item_viewed, show_group_as_sender, msg_signed, item_msg_body, item_chat_binding, item_signatures, item_signed_by_group_member_id, timed_ttl, timed_delete_at, + -- feed + item_feed, feed_item_id, -- quote quoted_shared_msg_id, quoted_sent_at, quoted_content, quoted_sent, quoted_member_id, -- forwarded from fwd_from_tag, fwd_from_chat_name, fwd_from_msg_dir, fwd_from_contact_id, fwd_from_group_id, fwd_from_chat_item_id, fwd_from_group_type, fwd_from_group_link, fwd_from_public_group_id, fwd_from_member_id, fwd_from_shared_msg_id - ) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) + ) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) Plan: @@ -5176,6 +5587,14 @@ Query: Plan: +Query: + INSERT INTO feed_jobs ( + feed_id, chat_item_id, worker_scope, action_tag, message_ids, + job_status, created_at, updated_at + ) VALUES (?,?,?,?,?,?,?,?) + +Plan: + Query: INSERT INTO file_badge_proofs (file_id, proof_kind, badge_proof, badge_pres_header, badge_key_idx, badge_type, badge_expiry, badge_extra, created_at, updated_at) VALUES (?,?,?,?,?,?,?,?,?,?) @@ -5259,6 +5678,14 @@ Query: Plan: SEARCH group_members USING INDEX idx_group_members_group_id_index_in_group (group_id=?) +Query: + SELECT DISTINCT feed_id, worker_scope + FROM feed_jobs + WHERE failed = 0 AND job_status = ? + +Plan: +SCAN feed_jobs USING COVERING INDEX idx_feed_jobs_next + Query: SELECT DISTINCT group_id, worker_scope FROM delivery_jobs @@ -5346,6 +5773,14 @@ SEARCH p USING INDEX idx_badge_purchases_store_receipt (badge_store_receipt_id=? CORRELATED SCALAR SUBQUERY 1 SEARCH p USING INDEX idx_badge_purchases_store_receipt (badge_store_receipt_id=?) +Query: + UPDATE chat_items + SET item_content = ?, item_text = ?, item_status = ?, item_deleted = ?, item_deleted_ts = ?, item_edited = ?, has_link = ?, updated_at = ? + WHERE user_id = ? AND feed_id = ? AND chat_item_id = ? + +Plan: +SEARCH chat_items USING INTEGER PRIMARY KEY (rowid=?) + Query: UPDATE chat_items SET item_content = ?, item_text = ?, item_status = ?, item_deleted = ?, item_deleted_ts = ?, item_edited = ?, item_live = ?, updated_at = ?, timed_ttl = ?, timed_delete_at = ? @@ -5386,6 +5821,14 @@ Query: Plan: SEARCH chat_items USING INTEGER PRIMARY KEY (rowid=?) +Query: + UPDATE chat_items + SET item_deleted = ?, item_deleted_ts = ?, updated_at = ? + WHERE user_id = ? AND feed_id = ? AND chat_item_id = ? + +Plan: +SEARCH chat_items USING INTEGER PRIMARY KEY (rowid=?) + Query: UPDATE chat_items SET item_deleted = ?, item_deleted_ts = ?, updated_at = ? @@ -5924,7 +6367,7 @@ Query: -- GroupInfo g.group_id, g.local_display_name, gp.display_name, gp.full_name, gp.short_descr, g.local_alias, gp.description, gp.image, gp.group_type, gp.group_link, gp.public_group_id, gp.group_web_page, gp.group_domain, gp.domain_web_page, gp.allow_embedding, gp.group_domain_proof, - g.enable_ntfs, g.send_rcpts, g.favorite, gp.preferences, gp.preferences_json, gp.member_admission, gp.chat_layout, + g.enable_ntfs, g.send_rcpts, g.favorite, g.drop_feed, gp.preferences, gp.preferences_json, gp.member_admission, gp.chat_layout, g.created_at, g.updated_at, g.chat_ts, g.user_member_profile_sent_at, g.conn_full_link_to_connect, g.conn_short_link_to_connect, g.conn_link_prepared_connection, g.conn_link_started_connection, g.welcome_shared_msg_id, g.request_shared_msg_id, g.business_chat, g.business_member_id, g.customer_member_id, @@ -5962,7 +6405,7 @@ Query: -- GroupInfo g.group_id, g.local_display_name, gp.display_name, gp.full_name, gp.short_descr, g.local_alias, gp.description, gp.image, gp.group_type, gp.group_link, gp.public_group_id, gp.group_web_page, gp.group_domain, gp.domain_web_page, gp.allow_embedding, gp.group_domain_proof, - g.enable_ntfs, g.send_rcpts, g.favorite, gp.preferences, gp.preferences_json, gp.member_admission, gp.chat_layout, + g.enable_ntfs, g.send_rcpts, g.favorite, g.drop_feed, gp.preferences, gp.preferences_json, gp.member_admission, gp.chat_layout, g.created_at, g.updated_at, g.chat_ts, g.user_member_profile_sent_at, g.conn_full_link_to_connect, g.conn_short_link_to_connect, g.conn_link_prepared_connection, g.conn_link_started_connection, g.welcome_shared_msg_id, g.request_shared_msg_id, g.business_chat, g.business_member_id, g.customer_member_id, @@ -5993,7 +6436,7 @@ Query: -- GroupInfo g.group_id, g.local_display_name, gp.display_name, gp.full_name, gp.short_descr, g.local_alias, gp.description, gp.image, gp.group_type, gp.group_link, gp.public_group_id, gp.group_web_page, gp.group_domain, gp.domain_web_page, gp.allow_embedding, gp.group_domain_proof, - g.enable_ntfs, g.send_rcpts, g.favorite, gp.preferences, gp.preferences_json, gp.member_admission, gp.chat_layout, + g.enable_ntfs, g.send_rcpts, g.favorite, g.drop_feed, gp.preferences, gp.preferences_json, gp.member_admission, gp.chat_layout, g.created_at, g.updated_at, g.chat_ts, g.user_member_profile_sent_at, g.conn_full_link_to_connect, g.conn_short_link_to_connect, g.conn_link_prepared_connection, g.conn_link_started_connection, g.welcome_shared_msg_id, g.request_shared_msg_id, g.business_chat, g.business_member_id, g.customer_member_id, @@ -6019,6 +6462,134 @@ SEARCH gp USING INTEGER PRIMARY KEY (rowid=?) SEARCH mu USING INDEX idx_group_members_group_id (user_id=? AND group_id=?) SEARCH pu USING INTEGER PRIMARY KEY (rowid=?) +Query: + SELECT + -- GroupInfo + g.group_id, g.local_display_name, gp.display_name, gp.full_name, gp.short_descr, g.local_alias, gp.description, gp.image, gp.group_type, gp.group_link, gp.public_group_id, + gp.group_web_page, gp.group_domain, gp.domain_web_page, gp.allow_embedding, gp.group_domain_proof, + g.enable_ntfs, g.send_rcpts, g.favorite, g.drop_feed, gp.preferences, gp.preferences_json, gp.member_admission, gp.chat_layout, + g.created_at, g.updated_at, g.chat_ts, g.user_member_profile_sent_at, + g.conn_full_link_to_connect, g.conn_short_link_to_connect, g.conn_link_prepared_connection, g.conn_link_started_connection, g.welcome_shared_msg_id, g.request_shared_msg_id, + g.business_chat, g.business_member_id, g.customer_member_id, + g.use_relays, g.relay_own_status, + g.ui_themes, g.summary_current_members_count, g.public_member_count, g.roster_version, g.custom_data, g.chat_item_ttl, g.members_require_attention, g.via_group_link_uri, g.group_domain_verified, + g.root_priv_key, g.root_pub_key, g.member_priv_key, + -- GroupMember - membership + mu.group_member_id, mu.group_id, mu.index_in_group, mu.member_id, mu.peer_chat_min_version, mu.peer_chat_max_version, mu.member_role, mu.member_category, + mu.member_status, mu.show_messages, mu.member_restriction, mu.invited_by, mu.invited_by_group_member_id, mu.local_display_name, mu.contact_id, mu.contact_profile_id, pu.contact_profile_id, + pu.display_name, pu.full_name, pu.short_descr, pu.description, pu.image, pu.contact_link, pu.chat_peer_type, pu.local_alias, pu.preferences, pu.preferences_json, + pu.badge_proof, pu.badge_pres_header, pu.badge_expiry, pu.badge_type, pu.badge_verified, pu.badge_extra, pu.badge_master_key, pu.badge_signature, pu.badge_key_idx, pu.contact_domain, pu.contact_domain_proof, pu.contact_domain_verified, + mu.created_at, mu.updated_at, + mu.support_chat_ts, mu.support_chat_items_unread, mu.support_chat_items_member_attention, mu.support_chat_items_mentions, mu.support_chat_last_msg_from_member_ts, mu.member_pub_key, mu.relay_link, mu.member_security_code, mu.member_security_code_verified_at + , i.chat_item_id + FROM groups g + JOIN group_profiles gp ON gp.group_profile_id = g.group_profile_id + JOIN group_members mu ON mu.group_id = g.group_id + JOIN contact_profiles pu ON pu.contact_profile_id = COALESCE(mu.member_profile_id, mu.contact_profile_id) + JOIN chat_items i ON i.group_id = g.group_id WHERE i.user_id = ? AND mu.contact_id = ? AND i.feed_item_id = ? AND i.group_id > ? AND i.item_deleted = 0 ORDER BY i.group_id ASC LIMIT ? +Plan: +SEARCH i USING INDEX idx_chat_items_feed_item_group (feed_item_id=? AND group_id>?) +SEARCH g USING INTEGER PRIMARY KEY (rowid=?) +SEARCH gp USING INTEGER PRIMARY KEY (rowid=?) +SEARCH mu USING INDEX idx_group_members_contact_id (contact_id=?) +SEARCH pu USING INTEGER PRIMARY KEY (rowid=?) + +Query: + SELECT + -- GroupInfo + g.group_id, g.local_display_name, gp.display_name, gp.full_name, gp.short_descr, g.local_alias, gp.description, gp.image, gp.group_type, gp.group_link, gp.public_group_id, + gp.group_web_page, gp.group_domain, gp.domain_web_page, gp.allow_embedding, gp.group_domain_proof, + g.enable_ntfs, g.send_rcpts, g.favorite, g.drop_feed, gp.preferences, gp.preferences_json, gp.member_admission, gp.chat_layout, + g.created_at, g.updated_at, g.chat_ts, g.user_member_profile_sent_at, + g.conn_full_link_to_connect, g.conn_short_link_to_connect, g.conn_link_prepared_connection, g.conn_link_started_connection, g.welcome_shared_msg_id, g.request_shared_msg_id, + g.business_chat, g.business_member_id, g.customer_member_id, + g.use_relays, g.relay_own_status, + g.ui_themes, g.summary_current_members_count, g.public_member_count, g.roster_version, g.custom_data, g.chat_item_ttl, g.members_require_attention, g.via_group_link_uri, g.group_domain_verified, + g.root_priv_key, g.root_pub_key, g.member_priv_key, + -- GroupMember - membership + mu.group_member_id, mu.group_id, mu.index_in_group, mu.member_id, mu.peer_chat_min_version, mu.peer_chat_max_version, mu.member_role, mu.member_category, + mu.member_status, mu.show_messages, mu.member_restriction, mu.invited_by, mu.invited_by_group_member_id, mu.local_display_name, mu.contact_id, mu.contact_profile_id, pu.contact_profile_id, + pu.display_name, pu.full_name, pu.short_descr, pu.description, pu.image, pu.contact_link, pu.chat_peer_type, pu.local_alias, pu.preferences, pu.preferences_json, + pu.badge_proof, pu.badge_pres_header, pu.badge_expiry, pu.badge_type, pu.badge_verified, pu.badge_extra, pu.badge_master_key, pu.badge_signature, pu.badge_key_idx, pu.contact_domain, pu.contact_domain_proof, pu.contact_domain_verified, + mu.created_at, mu.updated_at, + mu.support_chat_ts, mu.support_chat_items_unread, mu.support_chat_items_member_attention, mu.support_chat_items_mentions, mu.support_chat_last_msg_from_member_ts, mu.member_pub_key, mu.relay_link, mu.member_security_code, mu.member_security_code_verified_at + , i.chat_item_id + FROM groups g + JOIN group_profiles gp ON gp.group_profile_id = g.group_profile_id + JOIN group_members mu ON mu.group_id = g.group_id + JOIN contact_profiles pu ON pu.contact_profile_id = COALESCE(mu.member_profile_id, mu.contact_profile_id) + JOIN chat_items i ON i.group_id = g.group_id WHERE i.user_id = ? AND mu.contact_id = ? AND i.feed_item_id = ? AND i.group_id > ? AND i.item_feed = 1 ORDER BY i.group_id ASC LIMIT ? +Plan: +SEARCH i USING INDEX idx_chat_items_feed_item_group (feed_item_id=? AND group_id>?) +SEARCH g USING INTEGER PRIMARY KEY (rowid=?) +SEARCH gp USING INTEGER PRIMARY KEY (rowid=?) +SEARCH mu USING INDEX idx_group_members_contact_id (contact_id=?) +SEARCH pu USING INTEGER PRIMARY KEY (rowid=?) + +Query: + SELECT + -- GroupInfo + g.group_id, g.local_display_name, gp.display_name, gp.full_name, gp.short_descr, g.local_alias, gp.description, gp.image, gp.group_type, gp.group_link, gp.public_group_id, + gp.group_web_page, gp.group_domain, gp.domain_web_page, gp.allow_embedding, gp.group_domain_proof, + g.enable_ntfs, g.send_rcpts, g.favorite, g.drop_feed, gp.preferences, gp.preferences_json, gp.member_admission, gp.chat_layout, + g.created_at, g.updated_at, g.chat_ts, g.user_member_profile_sent_at, + g.conn_full_link_to_connect, g.conn_short_link_to_connect, g.conn_link_prepared_connection, g.conn_link_started_connection, g.welcome_shared_msg_id, g.request_shared_msg_id, + g.business_chat, g.business_member_id, g.customer_member_id, + g.use_relays, g.relay_own_status, + g.ui_themes, g.summary_current_members_count, g.public_member_count, g.roster_version, g.custom_data, g.chat_item_ttl, g.members_require_attention, g.via_group_link_uri, g.group_domain_verified, + g.root_priv_key, g.root_pub_key, g.member_priv_key, + -- GroupMember - membership + mu.group_member_id, mu.group_id, mu.index_in_group, mu.member_id, mu.peer_chat_min_version, mu.peer_chat_max_version, mu.member_role, mu.member_category, + mu.member_status, mu.show_messages, mu.member_restriction, mu.invited_by, mu.invited_by_group_member_id, mu.local_display_name, mu.contact_id, mu.contact_profile_id, pu.contact_profile_id, + pu.display_name, pu.full_name, pu.short_descr, pu.description, pu.image, pu.contact_link, pu.chat_peer_type, pu.local_alias, pu.preferences, pu.preferences_json, + pu.badge_proof, pu.badge_pres_header, pu.badge_expiry, pu.badge_type, pu.badge_verified, pu.badge_extra, pu.badge_master_key, pu.badge_signature, pu.badge_key_idx, pu.contact_domain, pu.contact_domain_proof, pu.contact_domain_verified, + mu.created_at, mu.updated_at, + mu.support_chat_ts, mu.support_chat_items_unread, mu.support_chat_items_member_attention, mu.support_chat_items_mentions, mu.support_chat_last_msg_from_member_ts, mu.member_pub_key, mu.relay_link, mu.member_security_code, mu.member_security_code_verified_at + , i.chat_item_id + FROM groups g + JOIN group_profiles gp ON gp.group_profile_id = g.group_profile_id + JOIN group_members mu ON mu.group_id = g.group_id + JOIN contact_profiles pu ON pu.contact_profile_id = COALESCE(mu.member_profile_id, mu.contact_profile_id) + JOIN chat_items i ON i.group_id = g.group_id WHERE i.user_id = ? AND mu.contact_id = ? AND i.feed_item_id = ? AND i.group_id > ? AND i.item_feed > 0 ORDER BY i.group_id ASC LIMIT ? +Plan: +SEARCH i USING INDEX idx_chat_items_feed_item_group (feed_item_id=? AND group_id>?) +SEARCH g USING INTEGER PRIMARY KEY (rowid=?) +SEARCH gp USING INTEGER PRIMARY KEY (rowid=?) +SEARCH mu USING INDEX idx_group_members_contact_id (contact_id=?) +SEARCH pu USING INTEGER PRIMARY KEY (rowid=?) + +Query: + SELECT + -- GroupInfo + g.group_id, g.local_display_name, gp.display_name, gp.full_name, gp.short_descr, g.local_alias, gp.description, gp.image, gp.group_type, gp.group_link, gp.public_group_id, + gp.group_web_page, gp.group_domain, gp.domain_web_page, gp.allow_embedding, gp.group_domain_proof, + g.enable_ntfs, g.send_rcpts, g.favorite, g.drop_feed, gp.preferences, gp.preferences_json, gp.member_admission, gp.chat_layout, + g.created_at, g.updated_at, g.chat_ts, g.user_member_profile_sent_at, + g.conn_full_link_to_connect, g.conn_short_link_to_connect, g.conn_link_prepared_connection, g.conn_link_started_connection, g.welcome_shared_msg_id, g.request_shared_msg_id, + g.business_chat, g.business_member_id, g.customer_member_id, + g.use_relays, g.relay_own_status, + g.ui_themes, g.summary_current_members_count, g.public_member_count, g.roster_version, g.custom_data, g.chat_item_ttl, g.members_require_attention, g.via_group_link_uri, g.group_domain_verified, + g.root_priv_key, g.root_pub_key, g.member_priv_key, + -- GroupMember - membership + mu.group_member_id, mu.group_id, mu.index_in_group, mu.member_id, mu.peer_chat_min_version, mu.peer_chat_max_version, mu.member_role, mu.member_category, + mu.member_status, mu.show_messages, mu.member_restriction, mu.invited_by, mu.invited_by_group_member_id, mu.local_display_name, mu.contact_id, mu.contact_profile_id, pu.contact_profile_id, + pu.display_name, pu.full_name, pu.short_descr, pu.description, pu.image, pu.contact_link, pu.chat_peer_type, pu.local_alias, pu.preferences, pu.preferences_json, + pu.badge_proof, pu.badge_pres_header, pu.badge_expiry, pu.badge_type, pu.badge_verified, pu.badge_extra, pu.badge_master_key, pu.badge_signature, pu.badge_key_idx, pu.contact_domain, pu.contact_domain_proof, pu.contact_domain_verified, + mu.created_at, mu.updated_at, + mu.support_chat_ts, mu.support_chat_items_unread, mu.support_chat_items_member_attention, mu.support_chat_items_mentions, mu.support_chat_last_msg_from_member_ts, mu.member_pub_key, mu.relay_link, mu.member_security_code, mu.member_security_code_verified_at + , i.chat_item_id + FROM groups g + JOIN group_profiles gp ON gp.group_profile_id = g.group_profile_id + JOIN group_members mu ON mu.group_id = g.group_id + JOIN contact_profiles pu ON pu.contact_profile_id = COALESCE(mu.member_profile_id, mu.contact_profile_id) + LEFT JOIN chat_items i ON i.feed_item_id = ? AND i.group_id = g.group_id WHERE g.user_id = ? AND mu.contact_id = ? AND g.business_chat = ? AND g.group_id > ? ORDER BY g.group_id ASC LIMIT ? +Plan: +SEARCH g USING INDEX idx_groups_user_id_business_chat (user_id=? AND business_chat=? AND group_id>?) +SEARCH gp USING INTEGER PRIMARY KEY (rowid=?) +SEARCH mu USING INDEX idx_group_members_group_id_index_in_group (group_id=?) +SEARCH pu USING INTEGER PRIMARY KEY (rowid=?) +SEARCH i USING COVERING INDEX idx_chat_items_feed_item_group (feed_item_id=? AND group_id=?) LEFT-JOIN + Query: SELECT cr.contact_request_id, cr.local_display_name, cr.agent_invitation_id, @@ -6053,6 +6624,35 @@ Plan: SEARCH cr USING INTEGER PRIMARY KEY (rowid=?) SEARCH p USING INTEGER PRIMARY KEY (rowid=?) +Query: + SELECT + m.group_member_id, m.group_id, m.index_in_group, m.member_id, m.peer_chat_min_version, m.peer_chat_max_version, m.member_role, m.member_category, m.member_status, m.show_messages, m.member_restriction, + m.invited_by, m.invited_by_group_member_id, m.local_display_name, m.contact_id, m.contact_profile_id, p.contact_profile_id, p.display_name, p.full_name, p.short_descr, p.description, p.image, p.contact_link, p.chat_peer_type, p.local_alias, p.preferences, p.preferences_json, + p.badge_proof, p.badge_pres_header, p.badge_expiry, p.badge_type, p.badge_verified, p.badge_extra, p.badge_master_key, p.badge_signature, p.badge_key_idx, p.contact_domain, p.contact_domain_proof, p.contact_domain_verified, + m.created_at, m.updated_at, + m.support_chat_ts, m.support_chat_items_unread, m.support_chat_items_member_attention, m.support_chat_items_mentions, m.support_chat_last_msg_from_member_ts, m.member_pub_key, m.relay_link, m.member_security_code, m.member_security_code_verified_at, + c.connection_id, c.agent_conn_id, c.conn_level, c.via_contact, c.via_user_contact_link, c.via_group_link, c.group_link_id, c.xcontact_id, c.custom_user_profile_id, + c.conn_status, c.conn_type, c.contact_conn_initiated, c.local_alias, c.contact_id, c.group_member_id, c.user_contact_link_id, + c.created_at, c.security_code, c.security_code_verified_at, c.pq_support, c.pq_encryption, c.pq_snd_enabled, c.pq_rcv_enabled, c.auth_err_counter, c.quota_err_counter, + c.conn_chat_version, c.peer_chat_min_version, c.peer_chat_max_version, + bp.badge_proof, bp.badge_pres_header, bp.badge_key_idx, bp.badge_type, bp.badge_expiry, bp.badge_extra + FROM group_members m + JOIN contact_profiles p ON p.contact_profile_id = COALESCE(m.member_profile_id, m.contact_profile_id) + LEFT JOIN connections c ON c.group_member_id = m.group_member_id + LEFT JOIN group_member_badge_proofs bp ON bp.group_member_id = m.group_member_id + + JOIN groups g ON g.group_id = m.group_id + WHERE m.user_id = ? AND g.business_chat = ? + AND m.group_id > ? AND m.group_id <= ? + AND (m.contact_id IS NULL OR m.contact_id != ?) + +Plan: +SEARCH m USING INDEX idx_group_members_group_id (user_id=? AND group_id>? AND group_id 0 Plan: -SEARCH contacts USING INDEX idx_contacts_chat_ts (user_id=?) +SEARCH contacts USING INDEX idx_contacts_user_id (user_id=?) Query: SELECT COUNT(1) FROM group_members WHERE member_role = 'owner' AND member_pub_key IS NOT NULL Plan: @@ -7694,6 +8359,30 @@ Plan: SCAN m USING COVERING INDEX idx_group_members_user_id_local_display_name SEARCH c USING INDEX idx_connections_group_member_id (group_member_id=?) +Query: SELECT chat_item_id FROM chat_item_messages WHERE message_id IN (SELECT message_id FROM msg_deliveries WHERE connection_id = ? AND agent_msg_id = ?) UNION SELECT i.chat_item_id FROM msg_deliveries d JOIN chat_item_messages cim ON cim.message_id = d.message_id JOIN chat_items i ON i.feed_item_id = cim.chat_item_id AND i.contact_id = ? WHERE d.connection_id = ? AND d.agent_msg_id = ? +Plan: +COMPOUND QUERY +LEFT-MOST SUBQUERY +SEARCH chat_item_messages USING INDEX sqlite_autoindex_chat_item_messages_1 (message_id=?) +LIST SUBQUERY 1 +SEARCH msg_deliveries USING INDEX idx_msg_deliveries_agent_msg_id (connection_id=? AND agent_msg_id=?) +UNION USING TEMP B-TREE +SEARCH d USING INDEX idx_msg_deliveries_agent_msg_id (connection_id=? AND agent_msg_id=?) +SEARCH cim USING INDEX sqlite_autoindex_chat_item_messages_1 (message_id=?) +SEARCH i USING COVERING INDEX idx_chat_items_feed_item_contact (feed_item_id=? AND contact_id=?) + +Query: SELECT chat_item_id FROM chat_item_messages WHERE message_id IN (SELECT message_id FROM msg_deliveries WHERE connection_id = ? AND agent_msg_id = ?) UNION SELECT i.chat_item_id FROM msg_deliveries d JOIN chat_item_messages cim ON cim.message_id = d.message_id JOIN chat_items i ON i.feed_item_id = cim.chat_item_id AND i.group_id = ? WHERE d.connection_id = ? AND d.agent_msg_id = ? +Plan: +COMPOUND QUERY +LEFT-MOST SUBQUERY +SEARCH chat_item_messages USING INDEX sqlite_autoindex_chat_item_messages_1 (message_id=?) +LIST SUBQUERY 1 +SEARCH msg_deliveries USING INDEX idx_msg_deliveries_agent_msg_id (connection_id=? AND agent_msg_id=?) +UNION USING TEMP B-TREE +SEARCH d USING INDEX idx_msg_deliveries_agent_msg_id (connection_id=? AND agent_msg_id=?) +SEARCH cim USING INDEX sqlite_autoindex_chat_item_messages_1 (message_id=?) +SEARCH i USING COVERING INDEX idx_chat_items_feed_item_group (feed_item_id=? AND group_id=?) + Query: SELECT chat_item_id FROM chat_items WHERE group_scope_tag = 'member_support' ORDER BY chat_item_id DESC LIMIT 1 Plan: SCAN chat_items @@ -7780,19 +8469,15 @@ SEARCH connections USING INDEX idx_connections_group_member_id (group_member_id= Query: SELECT contact_id FROM contacts WHERE user_id = ? AND (chat_item_ttl > 0 OR chat_item_ttl IS NULL) Plan: -SEARCH contacts USING INDEX idx_contacts_chat_ts (user_id=?) - -Query: SELECT contact_id FROM contacts WHERE user_id = ? AND (chat_item_ttl > 0) -Plan: -SEARCH contacts USING INDEX idx_contacts_chat_ts (user_id=?) +SEARCH contacts USING INDEX idx_contacts_user_id (user_id=?) Query: SELECT contact_id FROM contacts WHERE user_id = ? AND deleted = 0 Plan: -SEARCH contacts USING INDEX idx_contacts_chat_ts (user_id=?) +SEARCH contacts USING INDEX idx_contacts_user_id (user_id=?) Query: SELECT contact_id FROM contacts WHERE user_id = ? AND deleted = 1 Plan: -SEARCH contacts USING INDEX idx_contacts_chat_ts (user_id=?) +SEARCH contacts USING INDEX idx_contacts_user_id (user_id=?) Query: SELECT contact_id FROM contacts WHERE user_id = ? AND local_display_name = ? AND deleted = 0 Plan: @@ -7804,7 +8489,7 @@ SEARCH group_members USING COVERING INDEX idx_group_members_contact_id (contact_ Query: SELECT contact_id, conn_full_link_to_connect FROM contacts WHERE user_id = ? AND conn_short_link_to_connect = ? Plan: -SEARCH contacts USING INDEX idx_contacts_chat_ts (user_id=?) +SEARCH contacts USING INDEX idx_contacts_user_id (user_id=?) Query: SELECT contact_id, group_id FROM chat_items WHERE user_id = ? AND chat_item_id = ? Plan: @@ -7872,6 +8557,14 @@ Plan: SCAN badge_issuances USE TEMP B-TREE FOR ORDER BY +Query: SELECT feed_id FROM feeds WHERE user_id = ? +Plan: +SEARCH feeds USING COVERING INDEX idx_feeds_user_id (user_id=?) + +Query: SELECT feed_id FROM feeds WHERE user_id = ? LIMIT 1 +Plan: +SEARCH feeds USING COVERING INDEX idx_feeds_user_id (user_id=?) + Query: SELECT file_id FROM files WHERE user_id = ? AND redirect_file_id = ? Plan: SEARCH files USING INDEX idx_files_redirect_file_id (redirect_file_id=?) @@ -7904,10 +8597,6 @@ Query: SELECT group_id FROM groups WHERE user_id = ? AND (chat_item_ttl > 0 OR c Plan: SEARCH groups USING INDEX sqlite_autoindex_groups_2 (user_id=?) -Query: SELECT group_id FROM groups WHERE user_id = ? AND (chat_item_ttl > 0) -Plan: -SEARCH groups USING INDEX sqlite_autoindex_groups_2 (user_id=?) - Query: SELECT group_id FROM groups WHERE user_id = ? AND creating_in_progress = 1 AND created_at <= ? Plan: SEARCH groups USING INDEX sqlite_autoindex_groups_2 (user_id=?) @@ -8040,203 +8729,203 @@ Query: SELECT member_xcontact_id, member_welcome_shared_msg_id FROM group_member Plan: SEARCH group_members USING INTEGER PRIMARY KEY (rowid=?) -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '32316A574B414A435165634A50792F53' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '30684259584832555334657661412F39' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '34777371515341626273746F6A725531' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '32614636484A37622B4374324E4E5734' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '364C745457626A726943454F5139666D' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '337431703235696F434D4B3776434853' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '365431694F536951395477767543584B' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '354137562B536E777A2B2B5976484B4E' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '392F42343435485A4D6C4A4A42784179' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '3645794239544867616C7A5230777337' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '417A30336574747049655266542B536C' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '36796D58686E574266694C796B2B5A64' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '433045507738554A4F7579523533326F' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '38454B6B75746C674B742B517A394950' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '44797166387A61574D33377351566A70' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '433474434B6844723269533746426A56' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '47416E6C397937475639655A4F6A4872' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '436C776457752F4F4758744F65477546' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '47662F48747469674A782F4B6C485865' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '4370666F6A53764B684E68637A39746D' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '486F6247596E317158426C6857656B58' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '4751434D6275325A69712B61554A4E6F' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '4B474E46695541693956467863556162' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '484C6170574D614944537971777A7669' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '4B66326D76554F74434C3653464A6934' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '4A2B415448714F5967385848586A6769' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '4B6A54346C556543442B70736A657343' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '4B33725150425A6F5277596E534A7551' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '4C41445631472B445858565442547459' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '4B4137733650354D4362566944367642' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '4C424D4D41583853784C6A6769634C7A' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '4B5575585741435076462F6934543875' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '4E3530694B50794D6C6A386764364D36' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '4F45466E6456456B74642F574D665071' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '4F682F542F664E73554974746A646457' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '4F775272424B4C4131684F526C395254' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '4F6B396E4E486B7A4E7A2F505461306D' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '516B4462476C6D2B396D53432B4C6B68' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '4F6C47567330784972386E4B72496661' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '5339766F4A684E304B77343463576C68' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '51504E3266467468397A5A6A555A5A59' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '5361576E597874596267733555314955' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '516E6B70364443765466557A74576F51' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '53615971742F76583032584A412B5833' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '52346F3844796156594651305A6E6A4E' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '546637754F5761717A666C4847583149' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '525038584D53442F6863586C54706D70' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '554B4F715075666A4B634F7A5630506A' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '52567950695555535955742B7A6B432B' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '554C77396579547659524E2B4248582F' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '53526370717345687454376566784A52' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '5639776E53736C692B766A6B73323274' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '55455056465233397446394D36417837' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '577864516947395858632B2F45545A4B' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '55566967354649644E5644704E4E4578' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '5851797172594F51765562316C59376E' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '562B3130557347544E67734559524C35' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '595374322B2B6F6676367A736A39424C' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '57344B6B584E514C4B30727A6A56394B' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '61326E595634777947744A7277554749' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '57625336465661464B567538756A6C56' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '62684E644241506E46482B76795A7965' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '57786C587171347577326B6E4B343430' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '627A44706F776234526E437964486855' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '58326263487A776B576F5A322B452F56' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '64416E39776A394F7947696375357737' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '584F5873316B49463861366249744146' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '644C4D356F72463667374C4762596C73' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '614C4637486D4C3141774D42754E6958' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '655A5551576E6C324361523749344857' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '6164576959516B7051312F635174612F' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '6A6764546D684B74646544576B695377' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '62454B4B3074475654356464626C4331' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '6A757874527262483468777077795073' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '684D6135384C78366B2B435771687870' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '6A777A64354A44526163375150736D46' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '68565070767234594F4F4F3777783743' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '6C56537856546C6F456C78486478612B' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '6976634F5868363358575167476C5731' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '6D3158305A4574452F3173446B514C39' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '6D72486D5153563130647836586A784A' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '6E45332F706D395662305A4B53422B76' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '6F512B70507A763170634B2F77414D45' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '6E49697A726A6F754E7054544D76674F' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '7138444F774A364F492B6D4B56712F53' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '70476C3647416A306154324A6D415262' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '71684C516E6E423172626C595546536D' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '7138737130644431415A64526E487575' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '72395A612F30424B732B41375061344D' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '71694A7A695567334968654C73354F78' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '7351307538344376486B4A79664E687A' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '734D6661344346376C57644F61535941' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '7435356241497658594F334A42374767' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '7446724B50773850655A77644F6D716A' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '75413371367563467650575265516A6A' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '7546764B544B3445754D493734687932' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '79326A546878645A336346444D506B56' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '796954596A46663669517550646A2F71' Plan: SCAN messages -Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '794D423855453661496754424746484F' +Query: SELECT message_id FROM messages WHERE msg_sent = 0 AND hex(shared_msg_id) = '7A6D6D7464366842636E592F37506463' Plan: SCAN messages @@ -8345,10 +9034,18 @@ Query: SELECT shared_msg_id FROM chat_items WHERE shared_msg_id IS NOT NULL ORDE Plan: SCAN chat_items +Query: SELECT shared_msg_id, msg_body FROM messages WHERE message_id = ? AND shared_msg_id IS NOT NULL +Plan: +SEARCH messages USING INTEGER PRIMARY KEY (rowid=?) + Query: SELECT short_descr FROM contact_profiles WHERE display_name = ? LIMIT 1 Plan: SEARCH contact_profiles USING INDEX contact_profiles_index (display_name=?) +Query: SELECT short_descr FROM group_profiles +Plan: +SCAN group_profiles + Query: SELECT should_sync FROM connections_sync WHERE connections_sync_id = 1 Plan: SEARCH connections_sync USING INTEGER PRIMARY KEY (rowid=?) @@ -8487,10 +9184,26 @@ Query: UPDATE badge_store_receipts SET user_id = ?, payment = ?, next_attempt_at Plan: SEARCH badge_store_receipts USING INTEGER PRIMARY KEY (rowid=?) +Query: UPDATE chat_items SET item_content = ?, item_text = ?, item_edited = 1, has_link = ?, updated_at = ? WHERE user_id = ? AND feed_item_id = ? AND item_feed = 1 AND contact_id > ? AND contact_id <= ? +Plan: +SEARCH chat_items USING INDEX idx_chat_items_feed_item_contact (feed_item_id=? AND contact_id>? AND contact_id ? AND group_id <= ? +Plan: +SEARCH chat_items USING INDEX idx_chat_items_feed_item_group (feed_item_id=? AND group_id>? AND group_id