]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Search optimization - avoid parsing message_parts unnecessarily
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 17 Feb 2017 16:24:31 +0000 (18:24 +0200)
committerGitLab <gitlab@git.dovecot.net>
Sun, 19 Feb 2017 18:42:32 +0000 (20:42 +0200)
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

index 331a04cebfe90f0fad4f78a420c39367f7127953..0d9b3769aacdcfd46a0467b18205030f7a6cd5d8 100644 (file)
@@ -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);
 }