Re: query on a subset of messages ?
authorSebastien Binet <binet@cern.ch>
Mon, 9 Jul 2012 17:06:37 +0000 (19:06 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:48:05 +0000 (09:48 -0800)
28/5588715f64c583fb44fa24fc362c8c60164823 [new file with mode: 0644]

diff --git a/28/5588715f64c583fb44fa24fc362c8c60164823 b/28/5588715f64c583fb44fa24fc362c8c60164823
new file mode 100644 (file)
index 0000000..63cf339
--- /dev/null
@@ -0,0 +1,137 @@
+Return-Path: <sebastien.binet@cern.ch>\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 9B2C8431FD7\r
+       for <notmuch@notmuchmail.org>; Mon,  9 Jul 2012 10:06:40 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -5\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-5 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_HI=-5] autolearn=disabled\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 jJi0iYyGX5Um for <notmuch@notmuchmail.org>;\r
+       Mon,  9 Jul 2012 10:06:40 -0700 (PDT)\r
+Received: from CERNMX30.cern.ch (cernmx30.cern.ch [137.138.144.177])\r
+       (using TLSv1 with cipher AES128-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id BAC3F431FBF\r
+       for <notmuch@notmuchmail.org>; Mon,  9 Jul 2012 10:06:39 -0700 (PDT)\r
+Received: from CERNFE22.cern.ch (137.138.144.151) by cernmxgwlb2.cern.ch\r
+       (137.138.144.177) with Microsoft SMTP Server (TLS) id 14.2.283.3;\r
+       Mon, 9 Jul 2012 19:06:37 +0200\r
+Received: from localhost (134.158.88.68) by smtp.cern.ch (137.138.144.172)\r
+       with Microsoft SMTP Server (TLS) id 14.2.298.4; Mon, 9 Jul 2012 19:06:37\r
+       +0200\r
+From: Sebastien Binet <binet@cern.ch>\r
+To: Austin Clements <amdragon@MIT.EDU>\r
+Subject: Re: query on a subset of messages ?\r
+In-Reply-To: <20120709163000.GG18195@mit.edu>\r
+References: <871ukl5oj7.fsf@cern.ch> <20120709163000.GG18195@mit.edu>\r
+User-Agent: Notmuch/0.13.2+60~g7ecf77d (http://notmuchmail.org) Emacs/24.1.1\r
+       (x86_64-unknown-linux-gnu)\r
+Date: Mon, 9 Jul 2012 19:06:37 +0200\r
+Message-ID: <87obno3luq.fsf@cern.ch>\r
+MIME-Version: 1.0\r
+Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1;\r
+       protocol="application/pgp-signature"\r
+X-Originating-IP: [134.158.88.68]\r
+Keywords: CERN SpamKiller Note: -50\r
+Cc: Notmuch developer list <notmuch@notmuchmail.org>\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: Mon, 09 Jul 2012 17:06:40 -0000\r
+\r
+--=-=-=\r
+Content-Type: text/plain\r
+Content-Transfer-Encoding: quoted-printable\r
+\r
+Austin Clements <amdragon@MIT.EDU> writes:\r
+\r
+> Quoth Sebastien Binet on Jul 09 at 10:25 am:\r
+>>=20\r
+>> hi there,\r
+>>=20\r
+>> I was trying to reduce the I/O stress during my usual email\r
+>> fetching+tagging by writing a little program using the go bindings to\r
+>> notmuch.\r
+>>=20\r
+>> ie:\r
+>> db, status :=3D notmuch.OpenDatabase(db_path,\r
+>>                     notmuch.DATABASE_MODE_READ_WRITE)\r
+>> query :=3D db.CreateQuery("(tag:new AND tag:inbox)")\r
+>> msgs :=3D query.SearchMessages()\r
+>> for _,msg :=3D range msgs {\r
+>>   tag_msg(msg, tagqueries)\r
+>> }\r
+>>=20\r
+>>=20\r
+>> where tagqueries is a subquery of the form:\r
+>> [\r
+>>     {\r
+>>         "Cmd": "+to-me",\r
+>>         "Query": "(to:sebastien.binet@cern.ch and not tag:to-me)"\r
+>>     },\r
+>>     {\r
+>>         "Cmd": "+sci-notmuch",\r
+>>         "Query": "from:notmuch@notmuchmail.org or to:notmuch@notmuchmail=\r
+.org or subject:notmuch"\r
+>>     }\r
+>> ]\r
+>>=20\r
+>>=20\r
+>> the idea being that I only need to crawl through the db only once and\r
+>> then iteratively apply tags on those messages (instead of repeatedly\r
+>> running "notmuch tag ..." for each and every of those many\r
+>> 'tag-queries')\r
+>>=20\r
+>> I couldn't find any C-API to do such a thing using the notmuch library.\r
+>> did I overlook something ?\r
+>>=20\r
+>> Is it something useful to add ?\r
+>>=20\r
+>> -s\r
+>\r
+> Have you tried a more direct translation of the multiple notmuch tag\r
+> commands into Go, where you don't worry about subsetting the queries?\r
+> Unless you're tagging a huge number of messages, the cost of notmuch\r
+> tag is almost certainly the fsync that it does when it closes the\r
+> database (which every call to notmuch tag must do).  However, in Go,\r
+> you can keep the database open across all of the tagging operations\r
+> and then close and fsync it just once.\r
+\r
+nope, I haven't tried that, but will do.\r
+\r
+>\r
+> Note that there is an important optimization in notmuch tag that you\r
+> might have to replicate.  It manipulates the original query to exclude\r
+> messages that already have the desired tags, so that they get skipped\r
+> very efficiently at the earliest stage possible.\r
+I already have this in my original shell script.\r
+(wouldn't be too hard to automatically do, though.)\r
+\r
+=2Ds\r
+\r
+--=-=-=\r
+Content-Type: application/pgp-signature\r
+\r
+-----BEGIN PGP SIGNATURE-----\r
+Version: GnuPG v2.0.19 (GNU/Linux)\r
+\r
+iEYEARECAAYFAk/7D50ACgkQPj4AVbsZCCbNJQCgt63SDJf50TSrnZ/j6szzYHsu\r
+76EAoO3+PD1VEncWbu/uMckjhesXTOKu\r
+=rRi9\r
+-----END PGP SIGNATURE-----\r
+--=-=-=--\r