1 # Optimize notmuch's performance
3 ## Xapian 1.2.x database format: chert vs. flint
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`.
8 Check whether you are on chert or flint:
10 $ ls $(notmuch config get database.path)/.notmuch/xapian/iam*
13 If it does not say `iamchert`, but `iamflint`, than you should migrate
16 There might be a file named `flintlock`, it is no indicator for your
17 database format, but also used in case of `chert`.
19 ### Migrate from flint to chert
21 Make sure you are using xapian 1.2.x (depends on your distribution)
23 XXX: add examples for different distributions
25 Backup your notmuch tags:
28 $ notmuch dump notmuch-dump-b4chert
30 Move away your old database:
32 $ mv $(notmuch config get database.path)/.notmuch/ notmuch-db-b4chert
34 Find and import your messages, a new and fresh database will be
37 $ XAPIAN_PREFER_CHERT=1 notmuch new
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.
44 After the initial import it is definitely not necessary to define
45 `XAPIAN_PREFER_CHERT` for subsequent calls of `notmuch new`.
49 $ notmuch restore notmuch-dump-b4chert
51 Check whether you are on chert now:
53 $ ls $(notmuch config get database.path)/.notmuch/xapian/iam*
56 If it says `iamflint`, most likely you are still using xapian 1.0.x.
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:
63 $ rm notmuch-dump-b4chert
64 $ rm -R notmuch-db-b4chert
66 ### Compact your database
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
81 $ notmuch dump notmuch-dump-b4compact
85 $ cd $(notmuch config get database.path)/.notmuch
86 $ xapian-compact --no-renumber xapian xapian-compacted
88 Remove old and renamed compacted, if compacting went well:
91 $ mv xapian-compacted xapian
94 ### More information about this in the email archives:
96 * [Carl Worth](http://notmuchmail.org/pipermail/notmuch/2010/001105.html)
98 * [Sebastian Spaeth](http://notmuchmail.org/pipermail/notmuch/2011/004048.html)
100 * [Pieter Praet](http://notmuchmail.org/pipermail/notmuch/2011/004175.html)