DATA-ARCHITECT practice question 17 of 35
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?
Full set: 257 questionsWhen importing child records in a master-detail relationship, Salesforce places a lock on the parent record to update system fields, such as roll-up summaries. If child records for many different parents are interleaved in the import file, Salesforce repeatedly locks and unlocks different parent records, causing lock contention and failures. Sorting the child records by the parent ID (AccountID) ensures that all records for a single parent are processed in a contiguous block. This minimizes the number of times the parent record is locked, significantly reducing contention and preventing locking errors during a large data import.
A. Import Account records first followed by order records after sorting order by OrderID: Sorting by the child record's ID (OrderID) has no impact on parent record locking; the grouping must be by the parent ID.
C. Change the relationship to Lookup and update the relationship to master-detail after import: This is a complex, disruptive schema change and is not the standard, recommended first approach for mitigating lock contention during data loads.
D. Import Order records and Account records separately and populate AccountID in orders using batch Apex: This adds unnecessary complexity and an extra processing step. Standard data loading tools can handle this correctly if the data is sorted.
1. Salesforce Developer Documentation. (2023). Bulk API Developer Guide - Best Practices. "To avoid lock contention on the parent record when you load child records in a master-detail relationship, group the child records by parent ID."
2. Salesforce Architects. (2022). Record Locking Cheatsheet. "To prevent this [parent-child] lock, ensure that your data loading process sorts child records by their parent ID to minimize the number of times a parent record’s lock is acquired and released."
3. Salesforce. (2020). Large Data Volumes [PDF]. p. 12. "When inserting or updating child records in a Master-Detail relationship, the parent record is locked... To avoid this, sort the child records by the parent ID in the CSV file."
Keep practicing
Take the free DATA-ARCHITECT practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other DATA-ARCHITECT practice questions
- Question 1Which three characteristics of a skinny table help improve report and query performance?
- Question 2Universal Containers (UC) has built a custom application on Salesforce to help track ship…
- Question 3Universal Containers (UC) has lead assignment rules to assign leads to owners. Leads not …
- Question 4Universal Container (UC) has accumulated data over years and has never deleted data from …
- Question 5Universals Containers’ system administrators have been complaining that they are not able…
- Question 6Universal Containers is experiencing frequent and persistent group membership locking iss…
