A customer is facing locking issued when importing large data volumes of order records that are children in a master-detail relationship with the Account object. What is the recommended way to avoid locking issues during import?
A.
Import Account records first followed by order records after sorting order by OrderID.
B.
Import Account records first followed by order records after sorting orders by AccountID.
C.
Change the relationship to Lookup and update the relationship to master-detail after import.
D.
Import Order records and Account records separately and populate AccountID in orders using batch Apex.
B.
Import Account records first followed by order records after sorting orders by AccountID.
Explanation:
When dealing with master-detail relationships, Salesforce locks parent records (Accounts) during insertions or updates to child records (Orders) to maintain data integrity. Locking issues occur if multiple records associated with the same Account are processed simultaneously or out-of-order, causing database contention. Sorting child records (Orders) by the parent AccountID ensures that child records related to the same Account are processed sequentially, significantly reducing locking. Option A, sorting by OrderID, has no effect on parent record locking. Changing to Lookup (Option C) and reverting back is unnecessarily complicated and introduces data risks. Batch Apex (Option D) doesn’t inherently resolve the locking challenge and adds complexity. Hence, sorting child records by AccountID is Salesforce’s recommended best practice to mitigate locking during bulk data imports involving parent-child relationships.