1 # Optimize notmuch's performance
5 ## Xapian 1.2.x database format: chert vs. flint
7 Xapian 1.2 (in contrast to 1.0.x) uses a new database format called
8 `chert` which is a lot faster than the old format `flint`.
10 Check whether you are on chert or flint:
12 $ ls $(notmuch config get database.path)/.notmuch/xapian/iam*
15 If it does not say `iamchert`, but `iamflint`, than you should migrate
18 There might be a file named `flintlock`, it is no indicator for your
19 database format, but also used in case of `chert`.
21 ### Migrate from flint to chert
23 Make sure you are using xapian 1.2.x (depends on your distribution)
25 XXX: add examples for different distributions
27 Backup your notmuch tags:
30 $ notmuch dump notmuch-dump-b4chert
32 Move away your old database:
34 $ mv $(notmuch config get database.path)/.notmuch/ notmuch-db-b4chert
36 Find and import your messages, a new and fresh database will be
39 $ XAPIAN_PREFER_CHERT=1 notmuch new
41 I did not need the `XAPIAN_PREFER_CHERT`, but am not sure whether
42 there are situations making it necessary (certain compile-time options
43 to xapian?). This note is just here to be extended or removed by
44 somebody more knowledgeable.
46 After the initial import it is definitely not necessary to define
47 `XAPIAN_PREFER_CHERT` for subsequent calls of `notmuch new`.
51 $ notmuch restore notmuch-dump-b4chert
53 Check whether you are on chert now:
55 $ ls $(notmuch config get database.path)/.notmuch/xapian/iam*
58 If it says `iamflint`, most likely you are still using xapian 1.0.x.
60 Clean-up: if you are sure everything is fine, you can delete the old
61 things. The dump of your tags you might want to keep anyway as a
62 backup - on the other hand you should have some mechanism in place to
63 make regular 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 * [Carl Worth](http://notmuchmail.org/pipermail/notmuch/2010/001105.html)
100 * [Sebastian Spaeth](http://notmuchmail.org/pipermail/notmuch/2011/004048.html)
102 * [Pieter Praet](http://notmuchmail.org/pipermail/notmuch/2011/004175.html)
105 ## Tagging: use filters!
113 $ notmuch tag +foo -- not tag:foo
115 See the ongoing discussion:
117 * [Optimization for notmuch tag by implicit filters](http://notmuchmail.org/pipermail/notmuch/2011/004197.html)