In these times of effectively unlimited quotas, there’s no need to ever delete email. And I don’t—all my various accounts’ inboxes combined add up to somewhere around 20,000 emails. Having all your emails is great, but accessing them quickly is at least as important as having them on hand. However, of late, I’d been experiencing some severe performance problems in Mail.app—it was taking literally on the order of minutes for Mail to start up and shut down for me. Just brutal.
Today, in an effort to alleviate some of that pain, I stumbled across a solution that worked magnificently for me: cleaning up Mail.app’s SQLite database.
Here’s how you do it:
- Quit Mail.app.
- Launch Terminal, then type
cd ~/Library/Mail/
. - Back up
Envelope Index
in whatever fashion you prefer. I didcp Envelope\ Index EnvelopeIndexBackup
. - Open
Envelope Index
with SQLite:sqlite3 Envelope\ Index
. At thesqlite>
prompt, type:vacuum subjects;
. Once the prompt returns, type Ctrl-D or.exit
to quit SQLite.
This reduces the size of Mail.app’s database and cleans it up, usually to dramatic effect. I reduced my database from ~34 MB to ~22 MB, and Mail now starts up in seconds, not minutes. Boom!
References: procedure and information about the vacuum
statement.