From: Timo Sirainen Date: Fri, 17 Feb 2017 16:24:31 +0000 (+0200) Subject: lib-storage: Search optimization - avoid parsing message_parts unnecessarily X-Git-Tag: 2.3.0.rc1~2058 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7f93dd01f630d40ff81de471a437968f3dcfea87;p=thirdparty%2Fdovecot%2Fcore.git 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. --- 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); }