--- /dev/null
+Return-Path: <Sebastian@SSpaeth.de>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id C8286418C36\r
+ for <notmuch@notmuchmail.org>; Thu, 15 Apr 2010 23:38:57 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -1.9\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5\r
+ tests=[BAYES_00=-1.9] autolearn=ham\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id JScGQ97oeoq2 for <notmuch@notmuchmail.org>;\r
+ Thu, 15 Apr 2010 23:38:56 -0700 (PDT)\r
+Received: from homiemail-a20.g.dreamhost.com (caiajhbdcaib.dreamhost.com\r
+ [208.97.132.81])\r
+ by olra.theworths.org (Postfix) with ESMTP id 52CA2431FC1\r
+ for <notmuch@notmuchmail.org>; Thu, 15 Apr 2010 23:38:56 -0700 (PDT)\r
+Received: from localhost.localdomain (unknown [195.190.188.219])\r
+ by homiemail-a20.g.dreamhost.com (Postfix) with ESMTPA id 0CB017EC060; \r
+ Thu, 15 Apr 2010 23:38:54 -0700 (PDT)\r
+From: Sebastian Spaeth <Sebastian@SSpaeth.de>\r
+To: Notmuch developer list <notmuch@notmuchmail.org>\r
+Subject: [PATCH 3/3] notmuch-tag: don't sort messages before applying tag\r
+ changes\r
+Date: Fri, 16 Apr 2010 08:38:48 +0200\r
+Message-Id: <1271399928-6166-3-git-send-email-Sebastian@SSpaeth.de>\r
+X-Mailer: git-send-email 1.7.0.4\r
+In-Reply-To: <87eiifj433.fsf@SSpaeth.de>\r
+References: <87eiifj433.fsf@SSpaeth.de>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Fri, 16 Apr 2010 06:38:58 -0000\r
+\r
+It's not neccessary to sort the results before we apply tags. Xapian\r
+contributor Olly Betts says that savings might be bigger with a cold\r
+file cache and (as unsorted implies really sorted by document id) a better\r
+cache locality when applying tags to messages.\r
+\r
+Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>\r
+---\r
+ notmuch-tag.c | 3 +++\r
+ 1 files changed, 3 insertions(+), 0 deletions(-)\r
+\r
+diff --git a/notmuch-tag.c b/notmuch-tag.c\r
+index 8b6f7dc..fd54bc7 100644\r
+--- a/notmuch-tag.c\r
++++ b/notmuch-tag.c\r
+@@ -107,6 +107,9 @@ notmuch_tag_command (void *ctx, unused (int argc), unused (char *argv[]))\r
+ return 1;\r
+ }\r
+ \r
++ /* tagging is not interested in any special sort order */\r
++ notmuch_query_set_sort (query, NOTMUCH_SORT_UNSORTED);\r
++\r
+ for (messages = notmuch_query_search_messages (query);\r
+ notmuch_messages_valid (messages) && !interrupted;\r
+ notmuch_messages_move_to_next (messages))\r
+-- \r
+1.7.0.4\r
+\r