Some standard Salesforce objects maintain a special data relationship to facilitate record access under private sharing models. This is especially true of accounts and opportunities (and, in fact, is how account and opportunity teams are facilitated with regard to sharing and access to select records).
Account skew is the result of an account record having a large number of child records. I’ve seen this manifest with some clients as a single account record called Unassigned Accounts that has many tens of thousands of child account records that may be old, unused, or otherwise unassigned accounts. This scenario causes issues with performance and record locking.
When updates are made to a child record, Salesforce will lock the parent account record (to maintain record integrity in the database). Therefore, updating a large number of child records under the same account record will potentially cause contention (where multiple processes or operations try to access the same thing at the same time) with trying to lock the parent record (which is done using a separate system thread).
When updates are made to the parent account record, such as changing the owner, then all sharing will have to be recalculated on all child records. This can trigger a chain reaction because sharing rules, role hierarchy calculations, and many other operations related to sharing will have to take place. This will lead to long-running processes and potentially record locking issues.
To mitigate account skew, distribute child records across multiple parent account records. 10,000 is the magic number here. By distributing records across multiple accounts, we can avoid account skew and its performance impacts related to record locking and sharing operations.
Similar in principle to account skew, lookup skew can happen when there are a large number of child records associated (via the lookup field on those child records) with a single parent record. While account skew is specific to the account object, lookup skew can affect multiple objects.
Try the following to mitigate lookup skew:
We’ve explored the three types of data skew in Salesforce and how to mitigate them. When designing an effective data management strategy within Salesforce, be mindful of data skew and how it can affect performance. By designing for data skew from the outset when building a data strategy, even the largest orgs can perform without degradation.
Now we understand the different types of data skew and their impact, let’s combine what we’ve covered throughout this chapter.