Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 4844E431FBC for ; Wed, 23 Dec 2009 10:19:40 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 67vad1gYrklh for ; Wed, 23 Dec 2009 10:19:38 -0800 (PST) Received: from VA3EHSOBE006.bigfish.com (va3ehsobe005.messaging.microsoft.com [216.32.180.15]) by olra.theworths.org (Postfix) with ESMTP id 1F53D431FAE for ; Wed, 23 Dec 2009 10:19:38 -0800 (PST) Received: from mail164-va3-R.bigfish.com (10.7.14.239) by VA3EHSOBE006.bigfish.com (10.7.40.26) with Microsoft SMTP Server id 8.1.240.5; Wed, 23 Dec 2009 18:19:37 +0000 Received: from mail164-va3 (localhost.localdomain [127.0.0.1]) by mail164-va3-R.bigfish.com (Postfix) with ESMTP id 0C7981990649; Wed, 23 Dec 2009 18:19:37 +0000 (UTC) X-SpamScore: -20 X-BigFish: VPS-20(zz1418M1432R98dNzz1202hzzz32i6bh61h) X-Spam-TCS-SCL: 0:0 Received: from mail164-va3 (localhost.localdomain [127.0.0.1]) by mail164-va3 (MessageSwitch) id 1261592374181609_14289; Wed, 23 Dec 2009 18:19:34 +0000 (UTC) Received: from VA3EHSMHS025.bigfish.com (unknown [10.7.14.249]) by mail164-va3.bigfish.com (Postfix) with ESMTP id 217D9174807C; Wed, 23 Dec 2009 18:18:57 +0000 (UTC) Received: from ausb3extmailp02.amd.com (163.181.251.22) by VA3EHSMHS025.bigfish.com (10.7.99.35) with Microsoft SMTP Server (TLS) id 14.0.482.32; Wed, 23 Dec 2009 18:18:54 +0000 Received: from ausb3twp02.amd.com ([163.181.250.38]) by ausb3extmailp02.amd.com (Switch-3.2.7/Switch-3.2.7) with ESMTP id nBNIIoEn030592; Wed, 23 Dec 2009 12:18:54 -0600 X-WSS-ID: 0KV4AV8-02-CLS-02 X-M-MSG: Received: from sausexbh2.amd.com (SAUSEXBH2.amd.com [163.181.22.102]) by ausb3twp02.amd.com (Tumbleweed MailGate 3.7.2) with ESMTP id 2FF36FCC3B2; Wed, 23 Dec 2009 12:18:44 -0600 (CST) Received: from sausexmb4.amd.com ([163.181.3.15]) by sausexbh2.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 23 Dec 2009 12:18:49 -0600 Received: from optimon.amd.com ([163.181.34.104]) by sausexmb4.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 23 Dec 2009 12:18:48 -0600 Received: from mhdc-ns01.amd.com (mhdc-ns01.amd.com [165.204.35.147]) by optimon.amd.com (8.12.10/8.12.10) with ESMTP id nBNIImCG032389; Wed, 23 Dec 2009 12:18:48 -0600 Received: from testarossa.amd.com (testarossa.amd.com [165.204.147.44]) by mhdc-ns01.amd.com (8.13.8+Sun/8.13.8) with ESMTP id nBNIImru028811; Wed, 23 Dec 2009 11:18:48 -0700 (MST) Received: (from manderso@localhost) by testarossa.amd.com (8.13.1/8.13.1/Submit) id nBNIIjrK026982; Wed, 23 Dec 2009 11:18:45 -0700 X-Authentication-Warning: testarossa.amd.com: manderso set sender to MarkR.Andersom@amd.com using -f From: Mark Anderson To: Olly Betts , notmuch@notmuchmail.org In-Reply-To: References: <3wdskb8oh77.fsf@testarossa.amd.com> <87hbroyyf6.fsf@yoom.home.cworth.org> Date: Wed, 23 Dec 2009 11:18:45 -0700 Message-ID: <3wd637xo8oq.fsf@testarossa.amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-OriginalArrivalTime: 23 Dec 2009 18:18:48.0730 (UTC) FILETIME=[5F4C17A0:01CA83FC] X-Reverse-DNS: ausb3extmailp02.amd.com Subject: Re: [notmuch] Rather simple optimization for notmuch tag X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Dec 2009 18:19:40 -0000 On Wed, 23 Dec 2009 03:45:14 +0000, Olly Betts wrote: > Carl Worth writes: > > On Fri, 18 Dec 2009 00:49:00 -0700, Mark Anderson wrote: > > > I was updating my poll script that tags messages, and a common idiom is > > > to put > > > tag +mytag and not tag:mytag > > > > > > I don't know anything about efficiency, but for the simple single-tag > > > case, couldn't we imply the "and not tag:mytag" from the +mytag action > > > list for the tag command? > > > > On one level, it really shouldn't be a performance issue to tag messages > > that already have a particular tag. (And in fact, the recently proposed > > patches to fix Xapian defect 250 even address this I think.) > > Applying a filter up-front like this is likely to still help I think as it > avoids Xapian having to reverse-engineer this information internally. That's good to hear. > Actually, you could do this with multiple tags - you just need to build > a filter for documents which might be affected. > > So if you're adding tags a1 and a2, you want: AND_NOT (a1 AND a2) > since documents which already have tags a1 and a2 can be ignored. > > If you're removing d1 and d2, then the filter is: AND (d1 OR d2) > since documents have to be tagged d1 or d2 in order for the removal to > do anything. > > Handling a combination of removals and additions is trickier, but probably > possible, although the more tags you are dealing with, the less profitable > the filtering is likely to be (as the filter is likely to cull fewer > documents yet be more expensive to evaluate). But the transform is pretty simple, I think that any combination of additions and removals could be transformed according to the following formula. notmuch tag +a1 +a2 +a3 -d1 -d2 -d3 would transform to something like: and ( not(a1) or not(a2) or not(a3) or d1 or d2 or d3) There are certainly may be much more optimal ways to do it depending on the specific corpus of the database, considering if the tags a1 and a2 and a3 are usually added as one tag, or if the addition is done individually, because if I know that a3 implies a1 and a2, the first 3 terms could be combined to not(a1 and a2 and a3), or I could just exclude a3 tagged messages for nearly the same effect, with expected performance improvements. Unfortunately this requires that I know more about how the tags are used than I ever want notmuch to deal with. Perhaps a follow-on or parallel project with less emphasis on minimalism. This looks pretty good to me. Easy to implement and not likely to break things. I've been wondering about whether there should be a repository of mail added to the notmuch git so that we can start testing these kinds of features on a consistent body of mail. I doubt that I'll be the one to write this, since I don't have any time set aside for real coding, but if it takes long enough, I'll probably pick this one up eventually. -Mark