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