changeset 21600:236081fab146

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.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Fri, 17 Feb 2017 18:24:31 +0200
parents a90f51ba2e9c
children 15e700c083c0
files src/lib-storage/index/index-search.c
diffstat 1 files changed, 4 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/index-search.c	Fri Feb 17 18:19:46 2017 +0200
+++ b/src/lib-storage/index/index-search.c	Fri Feb 17 18:24:31 2017 +0200
@@ -774,7 +774,11 @@
 	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);
 }