Optimizing OS X Mail.app Performance



Mac OS X comes with a very usable e-mail client called Mail.app or simply Mail, but it tends to slow down a bit over time, especially when moving around large amounts of e-mails from multiple accounts.

This guide will help you optimize the performance of Mail. I've listed some useful tips for dealing with large hierarchically stored mail archives. To get the most out of these tips, you'll want to be using Mac OS X 10.4 (Tiger) or higher.

Optimizing Mail's Internal Database

What it does

Mail keeps track of your e-mail messages in several different locations, but the main location is the Library/Mail folder in your home directory. In this folder you will find every single e-mail message in each account stored as a separate file. Spotlight uses these files to keep track of e-mail contents.

Mail additionally stores a so-called Envelope Index which contains cross references between message subjects, contents and other interesting aspects. Over time, this index becomes less and less efficient and slows down Mail.

Luckily, the Envelope Index is stored as a database in a well known format. This enables you to use tools for optimizing performance, which sounds a lot more difficult than it really is.

Performing the optimization

Optimizing Mail's Envelope Index is very simple. Follow these simple instructions to make Mail snappy again:

  • Quit Mail from the menu or using Apple + Q and wait until the black arrow disappears from Mail's Dock icon.
  • Open up Terminal using Spotlight via Alt + Space or start it from the Applications/Utilities folder.
  • Type or copy the following line into the Terminal window:

sqlite3 ~/Library/Mail/Envelope\ Index vacuum

Finally, press Enter to perform the action and wait until it finishes, this can take anywhere from a few seconds to minutes depending on the amount of mail.

What has just happened?

The action performed in the Terminal will clean up Mail's internal database, saving disk space and speeding up the application. Dissecting the action bit by bit reveals the following:

  • sqllite3 refers to the command for manipulating the database. Mail uses the SQLite database library which provides the sqlite3 command line tool.
  • ~/Library/Mail/Envelope\ Index refers to the actual file in which Mail's database is stored.
  • vacuum refers to the action we want to perform on the database. Vacuuming is jargon for cleaning up unused space in the database and packing the data tightly together.

Example scenario

Of course I tried all this out on my own setup and I measured Mail's speed and index size prior to and after optimizing. The results are amazing.

Prior to optimization Mail took about ten seconds to start up and switching to other mailboxes took about as long. The Envelope Index was 12 megabytes in size, with my Mail folder totaling just around 51 megabytes.

After optimizing the index, Mail starts up in less than one second and switching mailboxes takes about as much. The Envelope Index is now 3 megabytes, which is four times smaller than before. My total Mail library now counts 42 megabytes.

The performance increase is really tremendous and I urge every Mail user to try this trick out, it will seem as if you have just bought a new Mac.

Now you might say that my mailbox is relatively small in size (see the following tip) but I do have more than 5.000 e-mails stored locally. Even with this dataset, the speedup is very evident.

Removing / Stripping Attachments

What it does

I use e-mail, thus Mail, for sending and receiving messages. For me, the message's text is often more important than attachments.

Over the years I have adopted a strict policy of saving important attachments to disk (where they belong) and stripping all attachments from the e-mail messages themselves.

This approach has several advantages:

  • Spotlight can index files on disk more efficiently than attachments to an e-mail.
  • Mail doesn't have to parse attachments, speeding up the application.
  • Backups are more usable since you can instantly use attachments without having to wade through e-mail messages.

How to do it

Of course, you will have to manually decide which attachments to keep and where to store them. You can use drag and drop into a Finder window to easily make copies of an attachment in a folder.

To strip or remove the attachments from the e-mail itself, use the Message --> Remove Attachments command in the menu bar.

Removing attachments (or stripping) this way only removes the attachment from a message and will leave the original text intact. So, you won't lose any text in the process and all of your e-mails are still indexed by Spotlight.

When removing attachments, Mail will replace each attachment with a single line of text, along the lines of:

[The attachment filename has been manually removed]

This enables you to use Spotlight to find back attachments belonging a message.

To speed up finding messages with attachments you can create a Smart Mailbox which lists all messages having attachments. Then, select all messages in that mailbox and use the Remove Attachments command to remove all attachments from all those messages, which may take some time.


I've been using the attachment stripping policy for about a half year now and it's been really helpful keeping the size of my library in check. Getting rid of abundant and obsolete attachments keeps Mail in good shape.

Combined with the tip above, I've been able to get my mailbox' size down to 42 megabytes coming from more than 180.

Although getting rid of attachments sounds scary initially, I'm sure you'll get used to filtering and only storing useful data.


Keeping Mail in shape: small investment, large payback

The tips mentioned above only take a little while to get used to but will really help keep the speed of Mail consistent.

After five months of heavy usage, my library deteriorated the performance of Mail and with a little manual cleaning I was back at optimal speed, while still maintaining an archive of over 5.000 e-mail messages.

Try the tips to see if they are helpful to you. I'm sure you won't be disappointed.

About this article

This article was added to the site on the 9th of March, 2007.

Other Apple Mac OS X articles

Check out these other articles about Apple and Mac OS X:

Back to top