This article explains how Thunderbird stores messages on the local disk drive and why it is necessary to compact messages periodically.
Table of Contents
How does Thunderbird store messages?
Thunderbird stores messages using the MBOX file format. With this file format, all the messages in each of Thunderbird's folders are concatenated and stored as plain text in a single file on the local hard drive (located into the Mail and ImapMail directories of your Profiles folder).
Why is compaction required?
As messages are added to a folder, the file containing the folder grows larger on the disk. However, when you delete a message or move it from one folder to another, the file on the disk does not automatically get smaller. This is because the original message is simply marked for deletion and hidden from view. It is not physically removed until you "compact" the folder. This temporarily improves performance in large folders but, in time, the large file is less efficient to work with. Therefore, in order to reclaim disk space and improve Thunderbird's performance, folders must be "compacted" periodically.
How does compaction work?
To compact a folder, Thunderbird opens the existing MBOX file on the disk (for example, the Inbox). Based on the rules for the MBOX mail format it reads the file one message at a time.
- If the message is still current, it is copied to a new temporary MBOX file, called Nstmp.
- If the message is marked as deleted or moved, Thunderbird skips that message and moves on to the next message.
This process is repeated one message at a time until the end of the file is reached. After that the original message storage file is deleted and the new one replaces it. This is followed by the generation of a new index for this message file (for example, called Inbox.msf).
When does compaction occur?
The compaction process is done automatically in Thunderbird (since version 5) when it saves more than 20 MB of space on the disk.
You can also launch a manual compaction request if needed:
- To compact a single folder, right-click on the folder and select .
- To compact all folders, select .
During a compaction process, progress is displayed in the Status Bar:
How can I configure compaction?
In themenu, you can:
- disable automatic compaction (which is not recommended because your folders won't be regularly cleaned of deleted messages)
- change the compaction threshold (for instance if you deal with a large volume of messages, you may use a larger threshold)