From 888dd0e3e740cde83db0a3c93f1b90d04b89dc6c Mon Sep 17 00:00:00 2001 From: flexsurfer Date: Tue, 31 May 2022 10:18:48 +0200 Subject: [PATCH] improve MarkAllRead performance (#2698) --- protocol/message_persistence.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/protocol/message_persistence.go b/protocol/message_persistence.go index cab30b008..6e819e20a 100644 --- a/protocol/message_persistence.go +++ b/protocol/message_persistence.go @@ -1456,7 +1456,7 @@ func (db sqlitePersistence) MarkAllRead(chatID string, clock uint64) (int64, int _ = 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 { return 0, 0, err } @@ -1466,7 +1466,7 @@ func (db sqlitePersistence) MarkAllRead(chatID string, clock uint64) (int64, int 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 { return 0, 0, err }