]> git.cworth.org Git - notmuch-wiki/blob - performance.mdwn
performance: use filters for tagging
[notmuch-wiki] / performance.mdwn
1 # Optimize notmuch's performance
2
3 [[!toc levels=2]]
4
5 ## Xapian 1.2.x database format: chert vs. flint
6
7 Xapian 1.2 (in contrast to 1.0.x) uses a new database format called
8 `chert` which is a lot faster than the old format `flint`.
9
10 Check whether you are on chert or flint:
11
12     $ ls $(notmuch config get database.path)/.notmuch/xapian/iam*
13     iamchert
14
15 If it does not say `iamchert`, but `iamflint`, than you should migrate
16 (read on).
17
18 There might be a file named `flintlock`, it is no indicator for your
19 database format, but also used in case of `chert`.
20
21 ### Migrate from flint to chert
22
23 Make sure you are using xapian 1.2.x (depends on your distribution)
24
25 XXX: add examples for different distributions
26
27 Backup your notmuch tags:
28
29     $ cd
30     $ notmuch dump notmuch-dump-b4chert
31
32 Move away your old database:
33
34     $ mv $(notmuch config get database.path)/.notmuch/ notmuch-db-b4chert
35
36 Find and import your messages, a new and fresh database will be
37 created:
38
39     $ XAPIAN_PREFER_CHERT=1 notmuch new
40
41 I did not need the `XAPIAN_PREFER_CHERT`, but am not sure whether
42 there are situations making it necessary (certain compile-time options
43 to xapian?). This note is just here to be extended or removed by
44 somebody more knowledgeable.
45
46 After the initial import it is definitely not necessary to define
47 `XAPIAN_PREFER_CHERT` for subsequent calls of `notmuch new`.
48
49 Restore your tags:
50
51     $ notmuch restore notmuch-dump-b4chert
52
53 Check whether you are on chert now:
54
55     $ ls $(notmuch config get database.path)/.notmuch/xapian/iam*
56     iamchert
57
58   If it says `iamflint`, most likely you are still using xapian 1.0.x.
59
60 Clean-up: if you are sure everything is fine, you can delete the old
61 things. The dump of your tags you might want to keep anyway as a
62 backup - on the other hand you should have some mechanism in place to
63 make regular backups of your notmuch database:
64
65     $ rm notmuch-dump-b4chert
66     $ rm -R notmuch-db-b4chert
67
68 ### Compact your database
69
70 In order to greatly reduce the size of your database, you should
71 compact it. Carl says "This functionality is not yet available in the
72 Xapian library interface or else I would probably make notmuch call it
73 after building the database." and Pieter "[compacting] will cause
74 writes to be a bit more expensive in the short term, but will
75 significantly reduce the db's size, which your SSD will surely
76 appreciate."
77
78 This needs xapian 1.2
79
80 Backup your database:
81
82     $ cd
83     $ notmuch dump notmuch-dump-b4compact
84
85 Compact it:
86
87     $ cd $(notmuch config get database.path)/.notmuch
88     $ xapian-compact --no-renumber xapian xapian-compacted
89
90 Remove old and renamed compacted, if compacting went well:
91
92     $ rm -R xapian
93     $ mv xapian-compacted xapian
94
95
96 ### More information about this in the email archives:
97
98 * [Carl Worth](http://notmuchmail.org/pipermail/notmuch/2010/001105.html)
99
100 * [Sebastian Spaeth](http://notmuchmail.org/pipermail/notmuch/2011/004048.html)
101
102 * [Pieter Praet](http://notmuchmail.org/pipermail/notmuch/2011/004175.html)
103
104
105 ## Tagging: use filters!
106
107 Instead of just:
108
109     $ notmuch tag +foo
110
111 use:
112
113     $ notmuch tag +foo -- not tag:foo
114
115 See the ongoing discussion:
116
117 http://notmuchmail.org/pipermail/notmuch/2011/004197.html