Compacting folders

Revision Information
  • Revision id: 225849
  • Created:
  • Creator: Wayne Mery
  • Comment: Add version 91 wording changes
  • Reviewed: Yes
  • Reviewed:
  • Reviewed by: firefox877
  • Is approved? No
  • Is current revision? No
  • Ready for localization: No
Revision Source
Revision Content

This article explains how Thunderbird stores messages on disk and why it is necessary to periodically compact folders. In verson 78 the term purge is used. In version 91, the term file maintenance is used.

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 reasons that are describd below), and so it is OK to allow a compact to proceed.

The compact prompt

The compact prompt appears when the compact threshold has been reached. You can click Proceed or Compact now to the allow compact, or you may click Cancel or Remind me later if the request to compact came at an inconvenient time. The prompt also has a checkbox, which you can mark to avoid being prompted in the future, and click "Proceed" or Compact now - then automatic compacts will happen in the background. 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, which makes an MBOX file larger, such as receiveing new mail.
  • Deleting a message, or filtering or moving it to another folder 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 with a compact (purge) operation.

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 to be freed by removing the gaps exceeds the threshold for automatic compact (configuration described below). Because deleting messages causes these gaps, it is common to see a prompt asking you to approve a compact after deleting a message.

How can I configure compact?

In Thunderbird > PreferencesTools > OptionsEdit > Preferences, you can search the term compact after which 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)
  • (in version 91) Change whether you get prompted

CompactTermSearchResults

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.

MBOX format

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 use compact, and so this article is not applicable Maildir folders.
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.

See also