Row-by-row updates instead of set-based updates

Don't use row operations, use set operations - always.

Using row operations is a near sure fire way to have degraded performance when something else better is available, and nearly 100% of the time, something better is available. I wrote about some, but not all, available patterns here.

Here is an example of a row operation that shouldn't be used: 

ttsBegin;

while select forUpdate custTrans

    where custTrans.TransDate < _cutoffDate

{

    custTrans.Blocked = CustVendorBlocked::All;

    custTrans.doUpdate();

}

ttsCommit;

The resolution for this, and a pattern that should be used nearly always is:

ttsBegin;

update_recordset custTrans

    setting Blocked = CustVendorBlocked::All

    where custTrans.TransDate < _cutoff;

ttsCommit;

we're doing the same amount of work between the two code examples but the update_recordSet execution will be signficantly faster. I've written in more detail about this and also here for lots of performance related topics, but the key take away is that set operators are almost always faster than row operators even with a set size of 1 - and as the set gets larger, set operators get more efficient. So there is no specific reason not to use set operators. X++ will handle all of the downgrades to row operators for us, if required, so we can code for the highest performance scenario and let the platform take care of the particulars. For inserts, you can use RecordInsertList / insert_recordset where appropriate. RecordInsertList is a personal favorite.