improve MarkAllRead performance (#2698)

This commit is contained in:
flexsurfer 2022-05-31 10:18:48 +02:00 committed by GitHub
parent 1bfde4c4cc
commit 888dd0e3e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -1456,7 +1456,7 @@ func (db sqlitePersistence) MarkAllRead(chatID string, clock uint64) (int64, int
_ = tx.Rollback() _ = tx.Rollback()
}() }()
seenResult, err := tx.Exec(`UPDATE user_messages SET seen = 1 WHERE local_chat_id = ? AND not(seen) AND clock_value <= ? AND not(mentioned)`, chatID, clock) seenResult, err := tx.Exec(`UPDATE user_messages SET seen = 1 WHERE local_chat_id = ? AND seen = 0 AND clock_value <= ? AND not(mentioned)`, chatID, clock)
if err != nil { if err != nil {
return 0, 0, err return 0, 0, err
} }
@ -1466,7 +1466,7 @@ func (db sqlitePersistence) MarkAllRead(chatID string, clock uint64) (int64, int
return 0, 0, err return 0, 0, err
} }
mentionedResult, err := tx.Exec(`UPDATE user_messages SET seen = 1 WHERE local_chat_id = ? AND not(seen) AND clock_value <= ? AND mentioned`, chatID, clock) mentionedResult, err := tx.Exec(`UPDATE user_messages SET seen = 1 WHERE local_chat_id = ? AND seen = 0 AND clock_value <= ? AND mentioned`, chatID, clock)
if err != nil { if err != nil {
return 0, 0, err return 0, 0, err
} }