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