Compacting folders

(Redirected from Compact Inbox or Other Folder)
Thunderbird Thunderbird Last updated: 4 weeks,1 day ago 78% of users voted this helpful
No one has helped translate this article yet. If you already know how localizing for SUMO works, start translating now. If you want to learn how to translate articles for SUMO, please start here.

This article 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.

How Thunderbird stores 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.

What compact does not do

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.

Is it OK to compact?

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

The Compact Folders prompt appears when the compact threshold has been reached.

TB91-compact-folders-prompt

You can choose Compact now to allow compacting to proceed, or Remind me later if the prompt came at an inconvenient time (in Thunderbird 78, the respective buttons were Proceed and Cancel). The prompt also has a checkbox: ☐ Compact folders automatically in the future. To avoid being prompted again, you can tick this option and choose Compact now (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 of dirt, are eventually removed (purged) with a compact operation.
Note: Compact does not apply to accounts using the Maildir storage format. Unlike MBOX, Maildir stores each message in a separate file, and deleting a message results in deleting the message file.

When does compact occur?

A compact happens when:

  • You right-click a folder and select Compact to compact a single folder
  • You select File > Compact Folders 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?

> PreferencesPreferences (formerly Options) > Network & Disk Space > Disk Space

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.

TB91-compact-folders-preferences-vs-prompt


How does compact work?

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:

Compacting folder message

Potential complications

Most users will experience no complications during or after the compact process. But because compact involves signficiant IO activity, some users might experience folder issues or slowness, even moreso if antivirus software monitoring is not excluding your Thunderbird profile directory. For more information see Compacting folders - Potential complications.

See also

Was this article helpful?

Please wait...

These fine people helped write this article:

Illustration of hands

Volunteer

Grow and share your expertise with others. Answer questions and improve our knowledge base.

Learn More