If you find Mail.app is getting a bit sluggish, it might be time to give it a spring clean. One option is to vacuum the database. There is no guarantee this will speed up Mail.app, but it is worth a try. Before doing this make sure you have a back-up of your Mail folders (/Library/Mail/V2/MailData). That should be as simple has having a current Time Machine backup.

You’ll need to issue the following command in Terminal.app:

sqlite3 ~/Library/Mail/V2/MailData/Envelope\ Index vacuum;

That command will work on OS X Lion and Mountain Lion. The command for Snow Leopard is:

/usr/bin/sqlite3 ~/Library/Mail/Envelope\ Index vacuum;

Let me know if it makes a difference to performance.

To see how much it reduces the size of your database you can issue this command before and after the vacuum command:

For Lion and Mountain Lion

ls -lah ~/Library/Mail/V2/MailData/Envelope\ Index

For Snow Leopard and earlier:

ls -lah ~/Library/Mail/Envelope\ Index

That command will show you the size of the database, with output looking something like this:

ls -lah ~/Library/Mail/V2/MailData/Envelope\ Index
-rw-r--r--@ 1 jonathan staff <span style="background-color: #ffff99;">63M</span> 17 Sep 11:52 /Users/jonathan/Library/Mail/V2/MailData/Envelope Index

The 2nd line is the output, the first is the command I used. The size info is the data I have highlighted in yellow.

Enhanced by Zemanta