Speeding up Mac Mail

Home >> Article >> Speeding up Mac Mail

I have been a Mac user for many years now, but have been less than pleased with Apple's Mail application recently due to the fact it takes so long to start up and then to find anything using its built in search. This has been a problem for me for some time, so I thought I would share a solution with those of you who might be experiencing similar issues.

 I am personally using Mac OS 10.7.5 (Lion) with Mail 5.3.

Namely it appears that Mail uses SQlite  as a database backend to manage your Mail. Well it is possible that this gets corrupted expecially if you manage as much Mail as I do and perhaps Mail crashes or is not shut down properly etc.

It turns out that with SQlite is similar to other datanases such as postgres and supports use of the 'vacuum' command to clean up your database, and in this case improve Mail's performance.

Here are some notes regarding SQlite's vacuum command:

The VACUUM command rebuilds the entire database. There are several reasons an application might do this:

  • Unless SQLite is running in "auto_vacuum=FULL" mode, when a large amount of data is deleted from the database file it leaves behind empty space, or "free" database pages. This means the database file might be larger than strictly necessary. Running VACUUM to rebuild the database reclaims this space and reduces the size of the database file.

  • Frequent inserts, updates, and deletes can cause the database file to become fragmented - where data for a single table or index is scattered around the database file. Running VACUUM ensures that each table and index is largely stored contiguously within the database file. In some cases, VACUUM may also reduce the number of partially filled pages in the database, reducing the size of the database file further.

  • Normally, the database page_size and whether or not the database supports auto_vacuum must be configured before the database file is actually created. However, when not in write-ahead log mode, the page_size and/or auto_vacuum properties of an existing database may be changed by using the page_size and/or pragma auto_vacuum pragmas and then immediately VACUUMing the database. When in write-ahead log mode, only the auto_vacuum support property can be changed using VACUUM.

http://www.sqlite.org/lang_vacuum.html

So how does this help us. Well as Mail uses sqllite to manage it mail, you can use the Vacuum command to clean up the mail database. Using the following command:

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 your performance especially of you have had problems in the past.

http://best-mac-tips.com/2012/09/17/vacuum-apple-mail-database/

Comments

The Lion / Mountain Lion version seems to have worked well for me with Mavericks.

Add new comment

By submitting this form, you accept the Mollom privacy policy.