Microsoft Exchange Client applications make frequent calls to MAPI table functions. Optimizing the use of table functions can result in significant performance improvements.
Efficient use of the IMAPITable::QueryRows method can improve performance when accessing table data. Instead of calling the IMAPITable::GetRowCount method and using the returned value in a subsequent call to QueryRows, first estimate the maximum number of rows possible in the table. Then call QueryRows(<large number>) to ask for all the rows at once. QueryRows returns the row count, along with the other information. If you do not get every row, request the remaining rows. To query all rows most efficiently, use the MAPI HrQueryAllRows function. See the MAPI Programmer’s Reference for details on this function.
It is also advantageous to run the QueryRows method on as many columns as needed in a single operation, and to use default formats. When rows and columns are not in the default format, queries usually incur more overhead.
For more information, see Ordering Function Calls to Ensure Table Notifications.
Efficient use of the SetColumns method also improves performance. Follow these guidelines:
Calls to the Restrict method are generally expensive to the server in terms of network overhead. For example, message tables are large. Therefore, restrictions are proportional to the number of messages in the database. Avoid doing a Restrict call whenever possible. Calls to Restrict for special tables like Rules and Forms are notable exceptions because the server is able to perform these restrictions in memory.