Home SalesforceInterview Question What is Data Skew?

What is Data Skew?

by Dhanik Lal Sahni

Skew means something is not right and in a data set, if the data is not distributed uniformly then it is referred to as Data skew. In Salesforce also when data is not uniformly assigned and we have more than 10,000 child records linked to the same parent or they are owned by a single owner, we call it Data Skew.

Data Skew Impact

Data Skew has a major effect on the performance of salesforce applications. This causes issues with record locking and sharing performance.

Types of Data Skew

Data skews are divided into below three categories that need to be addressed carefully for faster performance :

  • Account Data Skew
  • Ownership Data Skew
  • Lookup Data Skew

Let us understand all the above data skews.

1. Account Data Skew 

When we have a very large number of child records(>10,000) associated with the same account in salesforce, it is called Account Data Skew. 

Account Data Skew Solution

We should always try to avoid account data skew situations which will help to avoid locking and performance issues. Here are a few of the strategies for mitigating issues related to account data skew:

  • Whenever a single account has more than 10,000 child records, always try to create multiple accounts and link similar child records to their respective accounts.
  • If the skewed accounts are there, then we can re-distribute the child objects to reduce the record-level hurdles.
  • For skewed accounts, redistribute child objects in chunks during off-peak hours to reduce the impact of record-level locking.
  • Consider a Public Read/Write sharing model to avoid sharing recalculations for skewed accounts.

2. Ownership Data Skew

When a large number of records (>10,000) are owned by a single user then it results in an Ownership Skew. This will lead to performance issues while modification or sharing recalculation.

Ownership Data Skew Solution

We should avoid a large number of records being assigned to a single user.

  • Assign ownership to different users after every set of 10,000 records or data objects.
  • It is best to ensure the skewed owner(Owner of a record) does not have a role.
  • In cases where the skewed owner must hold a role, the role should be at the top of the hierarchy in its own branch of the role hierarchy.
  • Try to avoid keeping them in any public groups that could be used as the source of sharing rules.

3. Lookup Data Skew

When a large number of records are linked to a single object record through a lookup relationship, it is called a Lookup Skew. As it is possible to create lookup fields on any object in Salesforce, Lookup Skew can cause performance issues for any object.

Lookup Data Skew Solution
  1. Reducing Record Save Time
    • Increasing record save performance reduces the duration of locks, which reduces or eliminates lock failures, and has the added benefit of providing an enhanced end-user experience!
  2. Distributing the skew.
    • For lookup skew, the root of the problem is that a large number of records look up to a single record. We can distribute the skew to resolve the problem.
  3. Using a picklist field
    • When we have a low number of lookup values, it’s generally a good idea to use a picklist field rather than a lookup field to define those values. By defining those values as a picklist, we can eliminate locks associated with lookups on those records, which eliminates any kind of locking issues related to lookup skew. 

Summary:

To handle data skew

  • Avoid Large number (>10,000)of child records in master/detail relationship 
  • Avoid a Large Number of records owned by one user
  • Avoid Record Locking

References

Ownership Data Skew

Avoid Account Data Skew for Peak Performance

Similar Posts

What are Skinny Tables?

Queueable Vs Batch Apex In Salesforce

Salesforce Interview Question for Integration

What is Light DOM?

You may also like

2 comments

20 Scenario-based Salesforce Developer Interview Questions February 6, 2024 - 4:07 pm

[…]  What is Data Skew? […]

Reply
Questions for Tech Lead/Salesforce Architect Interview May 19, 2024 - 8:08 pm

[…] Salesforce Interview Question for Asynchronous ApexSalesforce Integration Interview QuestionsSalesforce Apex Interview QuestionTypes Of Integration Patterns in SalesforceDifference Between Custom Setting and Custom Metadata TypeWhat is PK Chunking?What is Data Skew? […]

Reply

Leave a Comment

Top 10 Salesforce Service Cloud Features Top 10 Best Practices for Lightning Flow Facts and Statistics for Salesforce’s Size and Market Share Top 5 Contract Management Salesforce Apps Top 10 Enterprise Integration Use Cases