1 [[!img notmuch-logo.png alt="Notmuch logo" class="left"]]
2 # Optimize notmuch's performance
6 ## Use of ecryptfs slows notmuch down.
8 I noticed that my `notmuch new` was really slow (several minutes) for
9 less then 20 new emails (around 20K in my database).
11 The performance tests in the notmuch source didn't show any real
12 issue, even on a non-encrypted ext4 fs.
14 After investigation and running different tests, a switch to a
15 LUKS-btrfs based filesystem to replace the ext4-ecryptfs resolved the
16 issue. It now takes some seconds to index hundreds of messages.
18 ## Xapian database format: chert vs. flint vs. glass
20 Depending on the Xapian version that was used during the initial notmuch
21 database creation, you might use another database format than the most recent
22 one, which is often faster.
24 Check whether you are on chert, flint or glass:
26 $ ls $(notmuch config get database.path)/.notmuch/xapian/iam*
29 If it does not say `iamglass`, but `iamchert` or `iamflint`, than you should
32 There might be a file named `flintlock`, it is no indicator for your database
33 format, but also used in case of `chert`.
35 ### Migrate from an older format to the most recent one (glass)
37 Make sure you are using xapian 1.4.x (depends on your distribution)
39 XXX: add examples for different distributions
41 Backup your notmuch tags:
44 $ notmuch dump --output=notmuch-dump-oldformat
46 Move away your old database:
48 $ mv $(notmuch config get database.path)/.notmuch/ notmuch-db.bak
50 Find and import your messages, a new and fresh database will be
57 $ notmuch restore --input=notmuch-dump-oldformat
59 Check whether you are on glass now:
61 $ ls $(notmuch config get database.path)/.notmuch/xapian/iam*
64 If it says `iamflint` or `iamchert`, most likely you are still using an old
67 Clean-up: if you are sure everything is fine, you can delete the old
68 things. The dump of your tags you might want to keep anyway as a
69 backup - on the other hand you should have some mechanism in place to
70 make regular backups of your notmuch database:
72 $ rm notmuch-dump-oldformat
73 $ rm -R notmuch-db.bak
75 ### Compact your database
77 In order to greatly reduce the size of your database, you should
78 compact it. Carl says "This functionality is not yet available in the
79 Xapian library interface or else I would probably make notmuch call it
80 after building the database." and Pieter "[compacting] will cause
81 writes to be a bit more expensive in the short term, but will
82 significantly reduce the db's size, which your SSD will surely
90 $ notmuch dump --output=notmuch-dump-b4compact
94 $ cd $(notmuch config get database.path)/.notmuch
95 $ xapian-compact --no-renumber xapian xapian-compacted
97 Remove old and renamed compacted, if compacting went well:
100 $ mv xapian-compacted xapian
103 ### More information about this in the email archives:
105 * [Carl Worth](https://notmuchmail.org/pipermail/notmuch/2010/001105.html)
107 * [Sebastian Spaeth](https://notmuchmail.org/pipermail/notmuch/2011/004048.html)
109 * [Pieter Praet](https://notmuchmail.org/pipermail/notmuch/2011/004175.html)