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 1. make sure you are using xapian 1.2.x (depends on your distribution)
25 2. Backup your notmuch tags
28 $ notmuch dump notmuch-dump-b4chert
30 3. Move away your old database
32 $ mv $(notmuch config get database.path)/.notmuch/ notmuch-db-b4chert
34 4. 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 6. 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.
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.
65 $ rm notmuch-dump-b4chert
66 $ rm -R notmuch-db-b4chert
68 ### Compact your database
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
83 $ notmuch dump notmuch-dump-b4compact
87 $ cd $(notmuch config get database.path)/.notmuch
88 $ xapian-compact --no-renumber xapian xapian-compacted
90 Remove old and renamed compacted, if compacting went well:
93 $ mv xapian-compacted xapian
96 ### More information about this in the email archives:
98 * [id:xyz, Carl Worth](http://notmuchmail.org/pipermail/notmuch/2010/001105.html)
100 * [id:xyz, Sebastian Spaeth](http://notmuchmail.org/pipermail/notmuch/2011/004048.html)
102 * [id:xyz, Pieter Praet](http://notmuchmail.org/pipermail/notmuch/2011/004175.html)