How to speed up Mac Mail in OS X Lion and Mountain Lion

If you use Apple's Mail app for OS X and have multiple accounts set up, you may have noticed some lagging issues, particularly if you're running Lion or Mountain Lion. I have been experiencing severe issues where Mail.app takes several seconds to catch up with what I am typing or performs poorly when loading messages which results in excruciatingly long wait times. One of my colleagues shared an interesting piece with me by Brett Terpstra that fixed it for me in just a few steps:

There was a tip on Hawk Wings long ago which showed how to speed up Apple’s Mail.app by vacuuming the SQLite3 index. I hadn’t tried it since Snow Leopard, but I was having some serious issues with the time it took to open a Mail folder on my Air, so I thought I’d give it a shot.

The problem seems to lie with the database of Mail, which is what houses all your messages and other information about them. With a simple terminal command, you can vacuum out the envelope index which should speed up the Mail database significantly.

I tried it on both my iMac and my MacBook Air and the results were pretty good. I can now tab through messages much more quickly, mass delete things without hiccups, and type emails without Mail lagging behind me.

Hit the link below to grab the command and try it for yourself. There's also instructions on how to set up an automatic script so you don't have to run it each and every time mail slows down. Let me know how it works for you!

Source: Brett Terpstra