mercredi 12 mars 2008

Speed up mail.app despite big mailboxes


My Mail.app inbox got too bulky again and was feeling sluggish, there are several ways to fix this issue. For reference, I have three mailboxes with over 3.5Gb of email ... Heck, I have emails from 1997! My first I do not want to loose ... ;-)

I found two ways to fix the issue, remove the "Envelope Index" file, which will mean that the index will be generated again ... and messages will have to be imported again - that sucks.

My second solution is the following, close mail.app and run my shell script!

My shell script:

8<----------------8<----------------8<----------------

#!/bin/sh

#Tell mail to quit (Applescript code taken from another blog)
osascript -e ‘tell application “Mail” to quit’

#Backup the index:
cp ~/Library/Mail/Envelope\ Index /tmp/

#Optimize, cleanup indices
sqlite3 ~/Library/Mail/Envelope\ Index 'vacuum addresses; vacuum messages; vacuum sqlite_sequence; vacuum attachments; vacuum properties; vacuum subjects; vacuum mailboxes; vacuum recipients; vacuum threads;'

8<----------------8<----------------8<----------------


Note: Everything between the two ' has to be on one line. This will cleanup the sqlite db and speed things up.



Worked for me. Might plan that on a monthly basis.

For the interested, what does vacuum do?
http://www.sqlite.org/lang_vacuum.html