--- /dev/null
+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 44EBD431FC0\r
+ for <notmuch@notmuchmail.org>; Thu, 19 Jul 2012 01:13:52 -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 BeLaeLKVqzwI for <notmuch@notmuchmail.org>;\r
+ Thu, 19 Jul 2012 01:13:51 -0700 (PDT)\r
+Received: from CERNMX32.cern.ch (cernmx32.cern.ch [137.138.144.178])\r
+ (using TLSv1 with cipher AES128-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 3F728431FAE\r
+ for <notmuch@notmuchmail.org>; Thu, 19 Jul 2012 01:13:51 -0700 (PDT)\r
+Received: from CERNFE22.cern.ch (137.138.144.151) by cernmxgwlb2.cern.ch\r
+ (137.138.144.178) with Microsoft SMTP Server (TLS) id 14.2.283.3;\r
+ Thu, 19 Jul 2012 10:13:46 +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;\r
+ Thu, 19 Jul 2012 10:13:46 +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: <87obno3luq.fsf@cern.ch>\r
+References: <871ukl5oj7.fsf@cern.ch> <20120709163000.GG18195@mit.edu>\r
+ <87obno3luq.fsf@cern.ch>\r
+User-Agent: Notmuch/0.13.2+77~g39beeb2 (http://notmuchmail.org) Emacs/24.1.1\r
+ (x86_64-unknown-linux-gnu)\r
+Date: Thu, 19 Jul 2012 10:13:25 +0200\r
+Message-ID: <87sjcoi2xm.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: Thu, 19 Jul 2012 08:13:52 -0000\r
+\r
+--=-=-=\r
+Content-Type: text/plain\r
+Content-Transfer-Encoding: quoted-printable\r
+\r
+Sebastien Binet <binet@cern.ch> writes:\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@notmuchmai=\r
+l.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
+FYI, I've put this into a new notmuch-mtag go-based binary over here:\r
+https://github.com/sbinet/notmuch/blob/dev/go-bindings/bindings/go/src/notm=\r
+uch-mtag/main.go\r
+\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
+iEYEARECAAYFAlAHwawACgkQPj4AVbsZCCaJrwCglm3LMNwaYJuCCCWGmGHt9WGv\r
+KB4An3LxEhxb//8thxBUNoOHQq5kluqn\r
+=1b+2\r
+-----END PGP SIGNATURE-----\r
+--=-=-=--\r