Using Sort Columns to Reduce Locking Issues


Using Sort Columns to Reduce Locking Issues


Solving Locking Issues

You can use the sort column to reduce locking issues on Salesforce. They recommend ordering a detail load table by the master record ID to improve locking. See https://developer.Salesforce.com/page/Loading_Large_Data_Sets_with_the_Force.com_Bulk_API for more information.

Here is a quick way you can add a Sort column to your load table. Assume that the load table is named “Account_upd1”:

 ALTER table Account_upd1

 ADD [Sort] int identity (1,1)

This adds a Sort column to the table that is a consecutive integer number.

Suppose you are uploading Contact records using a load table named “Contact_upd1”. You could create a Sort column as follows:

 ALTER table Contact_upd1

 ADD [Sort] int identity (1,1)

Then insert the source data into the Contact_upd1 table in AccountID order.

SF_TableLoader sends the records to Salesforce in AccountID order to reduce locking when inserting the contacts.

NOTE: Only use the Sort column functionality if you are receiving locking issue errors from the Salesforce server.