From 7f93dd01f630d40ff81de471a437968f3dcfea87 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Fri, 17 Feb 2017 18:24:31 +0200 Subject: [PATCH] lib-storage: Search optimization - avoid parsing message_parts unnecessarily If they're not already cached, the mail is parsed twice: once to get the message_parts and again to perform the actual search. The searching can however do the message_parts parsing internally as well. --- src/lib-storage/index/index-search.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib-storage/index/index-search.c b/src/lib-storage/index/index-search.c index 331a04cebf..0d9b3769aa 100644 --- a/src/lib-storage/index/index-search.c +++ b/src/lib-storage/index/index-search.c @@ -775,7 +775,11 @@ static int search_arg_match_text(struct mail_search_arg *args, i_zero(&body_ctx); body_ctx.index_ctx = ctx; body_ctx.input = input; + /* Get parts if they already exist in cache. If they don't, + message-search will parse the mail automatically. */ + ctx->cur_mail->lookup_abort = MAIL_LOOKUP_ABORT_NOT_IN_CACHE; (void)mail_get_parts(ctx->cur_mail, &body_ctx.part); + ctx->cur_mail->lookup_abort = MAIL_LOOKUP_ABORT_NEVER; return mail_search_args_foreach(args, search_body, &body_ctx); } -- 2.47.3