database error
[notmuch-archives.git] / b8 / 481f7df754f1ad9fa83594d48043c1214117d1
1 Return-Path: <sebastien.binet@cern.ch>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 44EBD431FC0\r
6         for <notmuch@notmuchmail.org>; Thu, 19 Jul 2012 01:13:52 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -5\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-5 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_HI=-5] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id BeLaeLKVqzwI for <notmuch@notmuchmail.org>;\r
16         Thu, 19 Jul 2012 01:13:51 -0700 (PDT)\r
17 Received: from CERNMX32.cern.ch (cernmx32.cern.ch [137.138.144.178])\r
18         (using TLSv1 with cipher AES128-SHA (128/128 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id 3F728431FAE\r
21         for <notmuch@notmuchmail.org>; Thu, 19 Jul 2012 01:13:51 -0700 (PDT)\r
22 Received: from CERNFE22.cern.ch (137.138.144.151) by cernmxgwlb2.cern.ch\r
23         (137.138.144.178) with Microsoft SMTP Server (TLS) id 14.2.283.3;\r
24         Thu, 19 Jul 2012 10:13:46 +0200\r
25 Received: from localhost (134.158.88.68) by smtp.cern.ch (137.138.144.172)\r
26         with Microsoft SMTP Server (TLS) id 14.2.298.4;\r
27         Thu, 19 Jul 2012 10:13:46 +0200\r
28 From: Sebastien Binet <binet@cern.ch>\r
29 To: Austin Clements <amdragon@MIT.EDU>\r
30 Subject: Re: query on a subset of messages ?\r
31 In-Reply-To: <87obno3luq.fsf@cern.ch>\r
32 References: <871ukl5oj7.fsf@cern.ch> <20120709163000.GG18195@mit.edu>\r
33         <87obno3luq.fsf@cern.ch>\r
34 User-Agent: Notmuch/0.13.2+77~g39beeb2 (http://notmuchmail.org) Emacs/24.1.1\r
35         (x86_64-unknown-linux-gnu)\r
36 Date: Thu, 19 Jul 2012 10:13:25 +0200\r
37 Message-ID: <87sjcoi2xm.fsf@cern.ch>\r
38 MIME-Version: 1.0\r
39 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1;\r
40         protocol="application/pgp-signature"\r
41 X-Originating-IP: [134.158.88.68]\r
42 Keywords: CERN SpamKiller Note: -50\r
43 Cc: Notmuch developer list <notmuch@notmuchmail.org>\r
44 X-BeenThere: notmuch@notmuchmail.org\r
45 X-Mailman-Version: 2.1.13\r
46 Precedence: list\r
47 List-Id: "Use and development of the notmuch mail system."\r
48         <notmuch.notmuchmail.org>\r
49 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
50         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
51 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
52 List-Post: <mailto:notmuch@notmuchmail.org>\r
53 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
54 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
55         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
56 X-List-Received-Date: Thu, 19 Jul 2012 08:13:52 -0000\r
57 \r
58 --=-=-=\r
59 Content-Type: text/plain\r
60 Content-Transfer-Encoding: quoted-printable\r
61 \r
62 Sebastien Binet <binet@cern.ch> writes:\r
63 \r
64 > Austin Clements <amdragon@MIT.EDU> writes:\r
65 >\r
66 >> Quoth Sebastien Binet on Jul 09 at 10:25 am:\r
67 >>>=20\r
68 >>> hi there,\r
69 >>>=20\r
70 >>> I was trying to reduce the I/O stress during my usual email\r
71 >>> fetching+tagging by writing a little program using the go bindings to\r
72 >>> notmuch.\r
73 >>>=20\r
74 >>> ie:\r
75 >>> db, status :=3D notmuch.OpenDatabase(db_path,\r
76 >>>                     notmuch.DATABASE_MODE_READ_WRITE)\r
77 >>> query :=3D db.CreateQuery("(tag:new AND tag:inbox)")\r
78 >>> msgs :=3D query.SearchMessages()\r
79 >>> for _,msg :=3D range msgs {\r
80 >>>   tag_msg(msg, tagqueries)\r
81 >>> }\r
82 >>>=20\r
83 >>>=20\r
84 >>> where tagqueries is a subquery of the form:\r
85 >>> [\r
86 >>>     {\r
87 >>>         "Cmd": "+to-me",\r
88 >>>         "Query": "(to:sebastien.binet@cern.ch and not tag:to-me)"\r
89 >>>     },\r
90 >>>     {\r
91 >>>         "Cmd": "+sci-notmuch",\r
92 >>>         "Query": "from:notmuch@notmuchmail.org or to:notmuch@notmuchmai=\r
93 l.org or subject:notmuch"\r
94 >>>     }\r
95 >>> ]\r
96 >>>=20\r
97 >>>=20\r
98 >>> the idea being that I only need to crawl through the db only once and\r
99 >>> then iteratively apply tags on those messages (instead of repeatedly\r
100 >>> running "notmuch tag ..." for each and every of those many\r
101 >>> 'tag-queries')\r
102 >>>=20\r
103 >>> I couldn't find any C-API to do such a thing using the notmuch library.\r
104 >>> did I overlook something ?\r
105 >>>=20\r
106 >>> Is it something useful to add ?\r
107 >>>=20\r
108 >>> -s\r
109 >>\r
110 >> Have you tried a more direct translation of the multiple notmuch tag\r
111 >> commands into Go, where you don't worry about subsetting the queries?\r
112 >> Unless you're tagging a huge number of messages, the cost of notmuch\r
113 >> tag is almost certainly the fsync that it does when it closes the\r
114 >> database (which every call to notmuch tag must do).  However, in Go,\r
115 >> you can keep the database open across all of the tagging operations\r
116 >> and then close and fsync it just once.\r
117 >\r
118 > nope, I haven't tried that, but will do.\r
119 >\r
120 >>\r
121 >> Note that there is an important optimization in notmuch tag that you\r
122 >> might have to replicate.  It manipulates the original query to exclude\r
123 >> messages that already have the desired tags, so that they get skipped\r
124 >> very efficiently at the earliest stage possible.\r
125 > I already have this in my original shell script.\r
126 > (wouldn't be too hard to automatically do, though.)\r
127 \r
128 FYI, I've put this into a new notmuch-mtag go-based binary over here:\r
129 https://github.com/sbinet/notmuch/blob/dev/go-bindings/bindings/go/src/notm=\r
130 uch-mtag/main.go\r
131 \r
132 \r
133 =2Ds\r
134 \r
135 --=-=-=\r
136 Content-Type: application/pgp-signature\r
137 \r
138 -----BEGIN PGP SIGNATURE-----\r
139 Version: GnuPG v2.0.19 (GNU/Linux)\r
140 \r
141 iEYEARECAAYFAlAHwawACgkQPj4AVbsZCCaJrwCglm3LMNwaYJuCCCWGmGHt9WGv\r
142 KB4An3LxEhxb//8thxBUNoOHQq5kluqn\r
143 =1b+2\r
144 -----END PGP SIGNATURE-----\r
145 --=-=-=--\r