Repeated calls against the same folder are slow in Exchange Server 2013 or Exchange Online

Symptoms

In Exchange Server 2013 or Exchange Online, when you repeatedly call the IMAPITable::Restrict() method in MAPI or the Folder.FindItems() method in Exchange Web Services by using the same filter criteria, subsequent calls against the same folder take as long to complete as the first call took.

This situation differs from that in earlier versions of Exchange. In those versions, later calls against the same folder are faster than the original call.

Cause

This issue occurs because Exchange Server 2013 does not cache every restriction. Earlier versions of Exchange cache every restriction. Therefore, repeated requests that use the same criteria are returned more quickly in those versions because the whole result set does not have to be recalculated.

Workaround

To work around this issue, create a search folder, and configure the folder criteria to match items that have the desired attributes. Then, query the search folder for the matching items. Because the search folder results are cached and kept up-to-date, the search folder results do not have to be recalculated every time that they are requested.

Note This workaround is applicable only if the same criteria is used every time. If the search criteria constantly changes, you may have to try an alternative method, such as a sort-and-seek process. For example, a search that is based on a particular datetime value would not use consistent criteria.

More Information

For more information about how to create search folders, see the following MSDN article: