Account skew – Understanding Salesforce sharing and security – Salesforce Data Architect Theory – Salesforce Certified Data Architect Study Guide

Account skew

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.

Account skew mitigation

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.

Lookup skew

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.

Lookup skew mitigation

Try the following to mitigate lookup skew:

  • Remove unnecessary workflows, process builders, or flows from affected objects in order to reduce saving time when records for affected objects are created or saved.
  • Distribute the skew across multiple records. For example, have separate parent object records for the lookups on the child records to reduce or even eliminate record locking and sharing recalculations.
  • Use picklist values instead of lookups. This will mean that there won’t be linking to actual parent records but reports on those picklist values can instead be used to query the associated data for a given parent record. This mitigation technique doesn’t lend itself to large amounts of lookup values, and therefore should only be used when the number of picklist values is low.

Data skew summary

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.