Here explains how Thunderbird stores messages on disk and why it is necessary to periodically compact folders. Compacting is a regular file maintenance process (sometimes referred to as “purging”) which recovers disk space without changing or removing any of your messages.
Thunderbird has two storage methods for folders:
- MBOX is the default format, where all of a folder’s messages are stored in a single file on disk. This is where the compact process is useful, and the purpose of this article is to explain how and why.
- Maildir is a newer storage format, where every message of a folder is a separate file. Maildir does not need compact, and so this article is not applicable to Maildir folders.
Compact (purge) is a maintenance process, so it:
- does not delete messages from folders
- does not remove messages from trash or spam folders
- does not compress folders by using compression algorithms such as zip
You may be concerned that the compact prompt sometimes appears just when you have deleted a message, or when you have started Thunderbird. This is expected behavior and is not cause for concern, because compact does not delete your messages.
Compact (purge) is normal maintenance (for the reasons described below), and so it is OK to allow a compact to proceed. The Compact Folders prompt appears when the compact threshold has been reached.
You can chooseto allow compacting to proceed, or if the prompt came at an inconvenient time (in Thunderbird 78, the respective buttons were Proceed and Cancel). The prompt also has a checkbox: . To avoid being prompted again, you can tick this option and choose (Proceed in Thunderbird 78) – then compacting will happen automatically in the background when necessary. If you do not wish to be prompted, we suggest you use the checkbox.
- Why is compact required?
Folders are stored by default in MBOX format, and these need periodic cleaning because your daily usage of Thunderbird involves:
- Adding messages to a folder, such as receiving new mail, which makes the MBOX file larger.
- Deleting messages, or filtering or moving them to another folder, which does *not* immediately make the MBOX file smaller. The folder does not get smaller because, for performance reasons, a deleted message is only logically marked for deletion. It becomes a gap which you can longer access, and the gaps, like bits if dirt, are eventually removed (purged) with a compact operation.
A compact happens when:
- You right-click a folder and select to compact a single folder
- You select to compact all folders in an account
- The amount of disk space to be freed by removing the gaps exceeds the threshold for automatic compact (configuration described below). Because deleting messages causes these gaps, you will often see the Compact Folders prompt just after deleting a message.
How can I configure compact?
> > >
In the preferences, you can:
- Disable automatic compact (not recommended because your folders will not be regularly cleaned of deleted messages)
- Change the compact threshold – a higher value will result in less frequent compacts (for example, if you deal with large messages or a large volume of messages, then you may want use a larger threshold)
- Choose if you want to get prompted or if you prefer automatic compacting without prompts (new in Thunderbird 91). Note: The checkbox in the preferences and the corresponding checkbox in the prompt will have reverse values because they are worded differently.
Thunderbird opens the MBOX file on the disk (for example, the Inbox), and 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 was marked as deleted or moved, that message is skipped and not moved to the mtemporary MBOX file.
This repeats until the end of the file is reached. Then the original storage file is deleted, the new one replaces it, and a new index for this message file is created (for example Inbox.msf). The end result is the gaps (the dirt) are gone.
During compact the progress is displayed in the Status Bar: