mirror of
https://github.com/chatmail/core.git
synced 2026-05-03 13:26:28 +03:00
feat: Add timestamp, id to msgs_index7 and speed up "normal chatlist" (#7848)
This commit is contained in:
@@ -272,15 +272,19 @@ impl Chatlist {
|
|||||||
AND m.id=(
|
AND m.id=(
|
||||||
SELECT id
|
SELECT id
|
||||||
FROM msgs
|
FROM msgs
|
||||||
WHERE chat_id=c.id
|
-- state=`OutDraft`.
|
||||||
AND (hidden=0 OR state=?)
|
WHERE state=19 AND hidden=1 AND chat_id=c.id
|
||||||
|
-- `InFresh`...`OutDelivered` inclusive except `OutDraft`.
|
||||||
|
OR state IN (10,13,16,18,20,24,26)
|
||||||
|
AND hidden=0
|
||||||
|
AND chat_id=c.id
|
||||||
ORDER BY timestamp DESC, id DESC LIMIT 1)
|
ORDER BY timestamp DESC, id DESC LIMIT 1)
|
||||||
WHERE c.id>9 AND c.id!=?
|
WHERE c.id>9 AND c.id!=?
|
||||||
AND (c.blocked=0 OR c.blocked=2)
|
AND (c.blocked=0 OR c.blocked=2)
|
||||||
AND NOT c.archived=?
|
AND NOT c.archived=?
|
||||||
GROUP BY c.id
|
GROUP BY c.id
|
||||||
ORDER BY c.id=0 DESC, c.archived=? DESC, IFNULL(NULLIF(m.timestamp,0),c.created_timestamp) DESC, m.id DESC;",
|
ORDER BY c.id=0 DESC, c.archived=? DESC, IFNULL(NULLIF(m.timestamp,0),c.created_timestamp) DESC, m.id DESC;",
|
||||||
(MessageState::OutDraft, skip_id, ChatVisibility::Archived, ChatVisibility::Pinned),
|
(skip_id, ChatVisibility::Archived, ChatVisibility::Pinned),
|
||||||
process_row,
|
process_row,
|
||||||
).await?
|
).await?
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2373,6 +2373,17 @@ ALTER TABLE contacts ADD COLUMN name_normalized TEXT;
|
|||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inc_and_check(&mut migration_version, 152)?;
|
||||||
|
if dbversion < migration_version {
|
||||||
|
sql.execute_migration(
|
||||||
|
"UPDATE msgs SET state=26 WHERE state=28;
|
||||||
|
DROP INDEX IF EXISTS msgs_index7;
|
||||||
|
CREATE INDEX msgs_index7 ON msgs (state, hidden, chat_id, timestamp, id);",
|
||||||
|
migration_version,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
|
||||||
let new_version = sql
|
let new_version = sql
|
||||||
.get_raw_config_int(VERSION_CFG)
|
.get_raw_config_int(VERSION_CFG)
|
||||||
.await?
|
.await?
|
||||||
|
|||||||
Reference in New Issue
Block a user