[Patch v5 6/8] lib: add private function to extract the database for a message.
[notmuch-archives.git] / bd / 4f05e435130a53c4ff6bb4bf59008f52f6fc0f
1 Return-Path: <tomi.ollila@iki.fi>\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 55757431FAF\r
6         for <notmuch@notmuchmail.org>; Mon,  2 Jun 2014 07:17:47 -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: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         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 a6qh5T1ss-aH for <notmuch@notmuchmail.org>;\r
16         Mon,  2 Jun 2014 07:17:38 -0700 (PDT)\r
17 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
18         by olra.theworths.org (Postfix) with ESMTP id 6B477431FAE\r
19         for <notmuch@notmuchmail.org>; Mon,  2 Jun 2014 07:17:38 -0700 (PDT)\r
20 Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
21         by guru.guru-group.fi (Postfix) with ESMTP id D19C710005E;\r
22         Mon,  2 Jun 2014 17:17:33 +0300 (EEST)\r
23 From: Tomi Ollila <tomi.ollila@iki.fi>\r
24 To: Mark Walters <markwalters1009@gmail.com>,\r
25         Vladimir Marek <Vladimir.Marek@oracle.com>, notmuch@notmuchmail.org\r
26 Subject: Re: Deduplication ?\r
27 In-Reply-To: <87d2ers9mi.fsf@qmul.ac.uk>\r
28 References: <20140602123212.GA12639@virt.cz.oracle.com>\r
29         <87d2ers9mi.fsf@qmul.ac.uk>\r
30 User-Agent: Notmuch/0.18+28~gcecaba1 (http://notmuchmail.org) Emacs/24.3.1\r
31         (x86_64-unknown-linux-gnu)\r
32 X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
33         $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
34         !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
35 Date: Mon, 02 Jun 2014 17:17:33 +0300\r
36 Message-ID: <m2ppirs8ea.fsf@guru.guru-group.fi>\r
37 MIME-Version: 1.0\r
38 Content-Type: text/plain\r
39 X-BeenThere: notmuch@notmuchmail.org\r
40 X-Mailman-Version: 2.1.13\r
41 Precedence: list\r
42 List-Id: "Use and development of the notmuch mail system."\r
43         <notmuch.notmuchmail.org>\r
44 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
45         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
46 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
47 List-Post: <mailto:notmuch@notmuchmail.org>\r
48 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
49 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
50         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
51 X-List-Received-Date: Mon, 02 Jun 2014 14:17:47 -0000\r
52 \r
53 On Mon, Jun 02 2014, Mark Walters <markwalters1009@gmail.com> wrote:\r
54 \r
55 > Vladimir Marek <Vladimir.Marek@oracle.com> writes:\r
56 >\r
57 >> Hi,\r
58 >>\r
59 >> I want to import bigger chunk of archived messages into my notmuch\r
60 >> database. It's about 100k messages. The problem is, that I most probably\r
61 >> have quite a lot of those messages in the DB. Basically I would like to\r
62 >> add only those I don't have already.\r
63 >>\r
64 >> There are two possibilities\r
65 >>\r
66 >> a) I will add all the 100k messages and then remove the duplicities.\r
67 >>\r
68 >> b) I will write a script which will parse the message ID's of the\r
69 >>    to-be-added messages and try to match them to the notmuch DB. Adding\r
70 >>    only files I can't find already.\r
71 >>\r
72 >> Ad b) might be better option, but I started to play with the idea of\r
73 >> deduplication. I'm thinking about listing all the message IDs stored in\r
74 >> DB, listing all files belonging to the IDs and deleting all but one.\r
75 >> Also I'm thinking about implementing some simple algorithm telling me\r
76 >> whether the messages are really very similar. Just to be sure I don't\r
77 >> delete something I don't want to.\r
78 >>\r
79 >> Was anyone playing with the idea?\r
80 >\r
81 > I am not sure what your use case is but notmuch automatically\r
82 > deduplicates: that is if the message-id is one it has already seen no\r
83 > further indexing takes place. The only thing that happens is the new\r
84 > filename gets added to the list of filenames for the message.\r
85 >\r
86 > Thus importing should be almost as fast as if the message were not\r
87 > there, and the database should be almost identical to what you would get\r
88 > if you only imported the genuine new messages.\r
89 >\r
90 > If you want to save disk space then you could delete the duplicates\r
91 > after with something like\r
92 >\r
93 > notmuch search --output=files --format=text0 --duplicate=2 '*' piped to\r
94 > xargs -0\r
95 \r
96 What if there are 3 duplicates (or 4... ;)\r
97 \r
98 >\r
99 > (but please test it carefully first!)\r
100 \r
101 One should also have some message content heuristics to determine that the\r
102 content is indeed duplicate and not something totally different (not that\r
103 we can see the different content anyway... but...)\r
104 \r
105 >\r
106 > I would think something like this is better than trying to parse the\r
107 > message-ids yourself.\r
108 \r
109 \r
110 >\r
111 > Best wishes\r
112 >\r
113 > Mark\r
114 >\r
115 \r
116 Tomi\r
117 \r
118 \r
119 >\r
120 >>\r
121 >> -- \r
122 >>      Vlad\r