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 compact it.
78 This can be easily achieved with `notmuch compact`:
82 Note that this process can take a long time for large database and a write lock
83 will be held for the duration to ensure data integrity. The process will create
84 a new compacted database in a temporary directory and finally replace the
85 original database if compaction is successful. For added safety you can provide
86 `--backup=<directory>` option to preserve a copy of the original database. For
87 more details on this process see `notmuch-compact` man page.
89 ### More information about this in the email archives:
91 * [Carl Worth](https://notmuchmail.org/pipermail/notmuch/2010/001105.html)
93 * [Sebastian Spaeth](https://notmuchmail.org/pipermail/notmuch/2011/004048.html)
95 * [Pieter Praet](https://notmuchmail.org/pipermail/notmuch/2011/004175.html)
97 ## Performance test suite
99 Notmuch ships with a [[performance test suite|perf-test]] which uses a downloadable