mirror of
https://github.com/chatmail/core.git
synced 2026-09-22 13:01:21 +03:00
perf: Add timestamp to msgs_index7 and speed up Chatlist::try_load() (#7848)
This speeds up chatlisting by 3--4 times on my biggest profile, so the difference is visually noticeable, particularly after dropping disk caches. Before, `msgs_index2` was used which has less ordering and requires a full scan of `msgs` table.
This commit is contained in:
@@ -2477,6 +2477,16 @@ UPDATE msgs SET state=24 WHERE state=18; -- Change OutPreparing to OutFailed.
|
||||
.await?;
|
||||
}
|
||||
|
||||
inc_and_check(&mut migration_version, 156)?;
|
||||
if dbversion < migration_version {
|
||||
sql.execute_migration(
|
||||
"DROP INDEX IF EXISTS msgs_index7;
|
||||
CREATE INDEX msgs_index7 ON msgs (state, hidden, chat_id, timestamp);",
|
||||
migration_version,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
||||
let new_version = sql
|
||||
.get_raw_config_int(VERSION_CFG)
|
||||
.await?
|
||||
|
||||
Reference in New Issue
Block a user