Mail.app Is Slow
So with 20972 messages in my Mail.app inbox, things were getting kinda slow. I looked to the West in search of a speed fix and found this Hawkwings.net post. Super!
The Fix Fails
Big problem: instead of the sqlite vacuum command vacuuming away my troubles as I dusted my Web Development trophy shelf, it coughed, choked and spat this error: SQL error: constraint failed. Huh? I dropped my duster.
There are literally hundreds of comments in that Hawk Wings post about happy Mail.app users gong from slow to go! And only two responses mentioning my error, neither of which cast light on getting around it.
So sullenly I went around the web looking for answers, turning over rocks, and generally knowing that if there were a real-life desert analog to this, my carcass would be getting picked over by vultures about now, if there were even vultures in this desolate landscape.
A Fix for the Fix?
Then deep within the comments of a Hawk Wings post about how to automate the happy vacuuming process — a jab I didn’t take kindly to — I found a post by regeya.
Essentially what I’m doing here is creating a new Envelope Index, setting the auto-vacuum pragma (which has to be done before any tables are added) then dumping the contents of the old index to the new file. Et viola, your index should be auto-vacuumed from now on.
Open up your Terminal and:
cd ~/Library/Mail mv Envelope\ Index Envelope\ Backup sqlite3 Envelope\ Index "PRAGMA auto_vacuum=1;" sqlite3 Envelope\ Backup ".dump" | sqlite3 Envelope\ Indexthen, after you’ve started up Mail.app and made sure everything’s working fine:
rm Envelope\ Backup
Bolds mine, and pay attention to them because the sentence summarizes the fix here — recreate recalcitrant databases entirely, which, from my years wandering the desert of Mail.app speedup methods, is the only way to defeat this error and speed up Mail.app.
It wasn’t all wine and roses however. After this command
sqlite3 Envelope\ Backup “.dump” | sqlite3 Envelope\ Index
I got: SQL error near line 124462: columns address, comment are not unique.
Plowing into the headwind I ran it again, and watched as my Terminal window scrolled 375,438 lines of errors. And as quickly as it began it was over.
The Dust Settles
I ran a list (ls) command in Terminal to make sure I still had data on my drive. I was surprised to see that it worked. Envelope Index’s size was 40.5 MB, and the backup’s was 48.0 MB. Stunned and dizzy, I picked up the duster and smiled. But I’m still a little wary.
Mail.app seems a little snappier, especially on startup, and I have an Envelop backup just in case.
Notes
I wouldn’t delete Envelope\ Backup (the last command of the quoted text, above) until you’ve given it a good few weeks to see if things are ok. And BE CAREFUL with these Terminal commands. If you’re not comfortable with Terminal, don’t mess with any of this.
