I have been using OSX Mail for a few years now and have noticed it getting slower and slower with each new OS release. This has become really bad in Sierra so I started to dig around to try and find and answer. Anyone who has the same issue will know that their does not appear to be any solutions and the problem seems to be being ignored by Apple. I currently have over 200,000 emails and it is just so slow now that I was at the point of giving up with Apple Mail.
I have done some research into what the Mail software is doing when querying the index database and this appears to be a big part of the slowness and spinning ball problems being seen by users.
What I have done is add 6 new indexes to the “messages” table and this has massively improved the speed of navigating the Mail messages and displaying messages as well as when composing emails (although the improvement is only slight) .
I thought I would share here in case it might help others.
The extra indexes I added where to the SQLite database that Apple Mail uses to index the messages and can be found in ~/Library/Mail/V4/MailData/Envelope Index and are as follows:
mailbox ASC, date_received DESC
Please be aware that I take no responsibility for screwing up your emails and this change is not for the novice.
If others find it useful then maybe someone might like to write a little Xojo program to apply the indexes for others to be able to use.
For anyone who is interested I have written a little program that applies the indexes to the Apple Mail Index database. I have tested this on two devices with different versions of OSX and it appears to apply the indexes etc correctly. It checks to see it Apple Mail is running as you need to exit it beforehand. In then attempts to make a backup of the database, then added the 6 indexes and does a reindex of the database. It should fail safe but obviously the usual warnings that this is used at your own risk and you must have a backup before using it in case it screws things up. Having said all of that the difference is huge for me. Before using the utility it could take up to 30 seconds for an email to display when clicking on it, now it takes between <1 and 3 seconds depending on the content. Also the problem that many people are experiencing whereby your typing gets delayed the longer the email also seems to have been resolved by this. I would welcome feedback. Thanks
The message.sender index seems to be there…
@Marius Dieter Noetzel Good spot, it should be DESC which is not already there, I will change my code, as this was in my original changes but was a typo in my first post, thanks.
@Marius Dieter Noetzel the messages.date_received is an ASC rather than a DESC and this appears to be the one that makes the main improvement.
Normally - as I know - single column indexes are not slower if they are scanned backwards. Index order is only interesting when having multi-column index.
I just did a test without the desc-index and with it. It was exactly the same time having mail to come up.
I agree it should not make a difference but I have read that if you are sorting data then the index order can make a difference. That said I have now removed the indexes I added and apple mail is still running just as quick so am totally confused why it is now quicker even without the extra indexes.
I used Mail several years but switched to Airmail 3. Blistering fast browsing through mails and searching mails.