Understand Thunderbird Folder Compaction Before Treating It as Message Deletion
A Thunderbird folder can contain fewer visible messages while its local storage file remains large. Before deleting more mail to chase the number, establish which storage format the account uses and what Thunderbird means by compacting.
Match the maintenance operation to the storage
In Thunderbird's default mbox format, a folder's messages share one storage file. Moving or deleting a message can leave unused space in that file. Compaction rewrites the remaining messages into a replacement file and reclaims those gaps. Maildir stores messages separately and does not need this process.
Compaction does not act as a second instruction to empty Trash, delete visible messages or create a ZIP archive. Thunderbird can offer it after enough reclaimable space accumulates. You can also select Compact from a folder's context menu, or Compact Folders from the File menu for an account.
Record the account and folder you intend to maintain. If the complaint is that important messages are already missing or the storage drive is failing, preserve the existing data and investigate that issue first. Routine space maintenance should not become an improvised recovery experiment.
Judge the result using two different observations
Choose a quiet maintenance window and keep the computer powered while the operation completes. Watch the application's progress rather than repeatedly starting another compact because the window appears busy. Note any exact error and the folder involved.
After completion, compare the local space used and check several retained messages from different dates. Open a known attachment as well as a message body. A smaller storage file is expected when gaps were present; a lower visible message count is not the intended success criterion.
If little space is reclaimed, do not assume compaction failed. The folder may contain little unused space, or the large data may belong to another folder. Establish the actual storage location before taking further action. Keep message retention decisions separate from the task of reclaiming already unused mbox space.
Source: Thunderbird documentation.