Improve TrimMainObjectSearch with LimitOnRowsReturned

Update

Jan comments that LimitOnRowsReturned adversely affects FastCount, the good news is that this is fixed in 82.  On the topic of FastCount there is a fix in the pipeline to improve its performance, at the moment if you call FastCount the SDK will trigger an extra, redundant, SELECT.  It is not always possible but I avoid FastCount where I can.

TrimMainObjectSearch may be used in a number of ways, sometimes to return all records matching a particular search criteria, other times (for example when supporting a user interface) to return only the first N records matching the search criteria.  If it is only the first N records you are interested in then use LimitOnRowsReturned (and PagingMode) to generate a more efficient SQL SELECT statement.

Written on November 29, 2015