Wednesday, April 24, 2024

Speed up Mail with a Vacuum

If you find 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, 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

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

Recent Articles


Related Stories


  1. Rats this seemed like what I need. I ran the vacuum several times and did not get an size reduction.

    Initial size: 112M –> vacuum –> revised index 112

    If I should do a re-start and then open terminal to run off fresh boot let me know. Also, I assume mail should be closed…

    Thank you.

    • Not sure what else to suggest.
      Have you tried rebuilding the mail index?
      MENUBAR > Mailbox > Rebuild

      Yes, I think it’s best to have Mail closed whilst vacuum cleaning it. Not sure running it after a fresh boot is likely to make any difference. But no harm is giving that a try.
      Upside is, you have a nice SMALL mailbox. My many mailboxes run into the many gigabytes each!!

  2. Hey Jonathan
    I ran this command in Terminal, and when I reopened Mail, my inbox was completely empty. Any ideas??
    Now I’m kind of stuck.

    • Hi Douglas. That’s a concern. I am sorry to hear that. As far as I am aware the vacuum command is not able to delete the mail data entirely. Did you copy and paste the command from the web page into Terminal? If not, scroll back in Terminal (just hit the up-arrow key from the command line) to find the command you run, and double check it was exactly as detailed on this web page.

      In order to rectify the issue: Do you have a current Time Machine back-up?
      Do you use POP3 or IMAP mail accounts?
      If using POP3, is Mail set to leave a copy on the server?
      If using IMAP, all your emails will still be on the server, and Mail should simply download them again.

      If using POP3 and emails are not set to be left on the server, then a back-up is going to be the easiest solution. However, in lieu of a recent back-up… there’s a chance the emails are still there on your computer.

      What happens when you run the Rebuild Mailbox command from within Mail?
      Before doing that, what comes up when you issue the command:

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

      from the command line?

      • whew – huge sigh of relief.
        the command you mentioned didn’t seem to do anything, but then when I rebuilt the mailbox within mail, it all came back to me.
        Many thanks for your assistance!

        • The command was to simply get some info on whether or not there was any data still there. It should have returned some info as indicated in the original Mac Tip article above.

          I am glad for you that a simple rebuild was all it took. I can feel your relief!!

Leave A Reply

Please enter your comment!
Please enter your name here

Stay on op - Ge the daily news in your inbox