aboutsummaryrefslogtreecommitdiffstats
path: root/worker
diff options
context:
space:
mode:
authorRobin Dapp <rdapp@modk.org>2024-07-22 11:09:59 +0200
committerRobin Jarry <robin@jarry.cc>2024-08-03 20:09:59 +0200
commitc36ed72e4a594b91f477782935d55c6a1cc1025d (patch)
tree67dd7d881600038a356ac9d5afede99d9c743875 /worker
parenta8894a50d94f19ce77646048a0f07a496383b14a (diff)
downloadaerc-c36ed72e4a594b91f477782935d55c6a1cc1025d.tar.gz
notmuch: speed up lastmod query.
When changing the tag/label of a message we refresh all messages that were modified since the start of the transaction. To that end we add "lastmod before..now" to the current query without any conjunction. That would make us re-index basically all messages. This patch wraps the existing query in parentheses and ANDs it with "lastmod" instead which greatly speeds up the process. Signed-off-by: Robin Dapp <rdapp@modk.org> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'worker')
-rw-r--r--worker/notmuch/eventhandlers.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/worker/notmuch/eventhandlers.go b/worker/notmuch/eventhandlers.go
index db490949..e4c2536e 100644
--- a/worker/notmuch/eventhandlers.go
+++ b/worker/notmuch/eventhandlers.go
@@ -70,7 +70,7 @@ func (w *worker) updateChangedMessages() error {
return nil
}
w.w.Logger.Debugf("State change: %d to %d", w.state, newState)
- query := fmt.Sprintf("%s lastmod:%d..%d", w.query, w.state, newState)
+ query := fmt.Sprintf("lastmod:%d..%d and (%s)", w.state, newState, w.query)
uids, err := w.uidsFromQuery(context.TODO(), query)
if err != nil {
return fmt.Errorf("Couldn't get updates messages: %w", err)