mirror of
https://github.com/chatmail/core.git
synced 2026-04-22 16:06:30 +03:00
feat: Add timestamp to msgs_index7 to employ it in calc_sort_timestamp()
Tested on some random chat, the SQL query took 1.411202ms (vs 6.692714ms before) in median. Still looks a bit slow, but already better.
This commit is contained in:
@@ -1271,6 +1271,18 @@ CREATE INDEX gossip_timestamp_index ON gossip_timestamp (chat_id, fingerprint);
|
||||
.await?;
|
||||
}
|
||||
|
||||
inc_and_check(&mut migration_version, 135)?;
|
||||
if dbversion < migration_version {
|
||||
// Tweak the index for `chat::calc_sort_timestamp()`.
|
||||
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);",
|
||||
migration_version,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
||||
let new_version = sql
|
||||
.get_raw_config_int(VERSION_CFG)
|
||||
.await?
|
||||
|
||||
Reference in New Issue
Block a user