]> git.cworth.org Git - notmuch-wiki/blob - performance.mdwn
notmuch performance: chert vs flint, compacting
[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 1. make sure you are using xapian 1.2.x (depends on your distribution)
22
23 XXX: add examples
24
25 2. Backup your notmuch tags
26
27     $ cd
28     $ notmuch dump notmuch-dump-b4chert
29
30 3. Move away your old database
31
32     $ mv $(notmuch config get database.path)/.notmuch/ notmuch-db-b4chert
33
34 4. 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 5. Restore your tags
48
49     $ notmuch restore notmuch-dump-b4chert
50
51 6. 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 7. Clean-up
59
60 If you are sure everything is fine, you can delete the old things. The
61 dump of your tags you might want to keep anyway as a backup - on the
62 other hand you should have some mechanism in place to make regular
63 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 * [id:xyz, Carl Worth](http://notmuchmail.org/pipermail/notmuch/2010/001105.html)
99
100 * [id:xyz, Sebastian Spaeth](http://notmuchmail.org/pipermail/notmuch/2011/004048.html)
101
102 * [id:xyz, Pieter Praet](http://notmuchmail.org/pipermail/notmuch/2011/004175.html)
103