0% found this document useful (0 votes)
37 views12 pages

Data Skew in Salesforce

This document discusses data skew in Salesforce, which refers to performance issues that occur when a large number of records are associated with a single record. It describes three types of data skew: ownership skew, lookup skew, and account data skew. It provides examples and solutions for each type and gives best practices for mitigating data skew such as distributing data evenly, using asynchronous processes, optimizing sharing settings, monitoring performance, and indexing critical fields.

Uploaded by

Mahesh Babu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views12 pages

Data Skew in Salesforce

This document discusses data skew in Salesforce, which refers to performance issues that occur when a large number of records are associated with a single record. It describes three types of data skew: ownership skew, lookup skew, and account data skew. It provides examples and solutions for each type and gives best practices for mitigating data skew such as distributing data evenly, using asynchronous processes, optimizing sharing settings, monitoring performance, and indexing critical fields.

Uploaded by

Mahesh Babu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Data Skew in Salesforce

#kb_sfdc_content
1. Introduction to Data Skew in Salesforce
2. Types of Data Skew
- 2.1 Ownership Skew
- 2.2 Lookup Skew
- 2.3 Account Data Skew
3. Best Practices to Mitigate Data Skew
- Distribute Data Evenly
- Use Asynchronous Processes
- Optimize Sharing Settings
- Monitor Performance
- Index Critical Fields

#kb_sfdc_content
1. What Is Data Skew
Data skew refers to performance and data integrity issues that occur when a large number of records are
associated with a single record in Salesforce.

This can create an imbalance that impacts system performance, particularly during updates or when sharing
calculations are being performed.

2. There are three primary types of data skew:

2.1) Ownership Skew


2.2) Lookup Skew
2.3) Account Data Skew.

#kb_sfdc_content
2.1) Ownership Skew

Ownership skew happens when a single user owns more than 10,000 records of a single object.
This can lead to performance issues because Salesforce must recalculate sharing rules every time a record is updated.
If the user is part of a role hierarchy, any changes to their role can cause extensive sharing recalculations.

Example:

- A user named "John Doe" owns 15,000 Account records.


- When any record owned by John Doe is updated, Salesforce recalculates the sharing rules for all 15,000 records.
- This can lead to significant delays and performance degradation, especially if the recalculations are frequent.

#kb_sfdc_content
Solution:

- Distribute record ownership among multiple users.


- Implement batch processes to handle large data updates during off-peak hours.
- Use public read/write groups where possible to minimize sharing recalculations.

#kb_sfdc_content
2.2) Lookup Skew

Lookup skew occurs when a large number of records look up to a single record within a lookup relationship. This can
create performance issues during updates or deletions because the parent record is locked to maintain data integrity.

Example:

- An object called "Order" has a lookup relationship to the "Customer" object.


- If 50,000 orders are associated with a single customer, updating or deleting the customer record can cause locking and
performance issues.
- The database may lock the "Customer" record to maintain referential integrity, delaying other operations on the
"Order" records.

#kb_sfdc_content
Solution:

- Distribute child records across multiple parent records.


- Use indexed fields in lookup relationships to improve query performance.
- Avoid single points of failure by ensuring that lookup fields distribute load evenly.

#kb_sfdc_content
2.3) Account Data Skew

Account Data Skew is a specific type of ownership skew related to the Account object. It occurs when a large
number of child records (like Contacts, Opportunities, or Cases) are associated with a single Account.

Example:

- An "Account" called "GlobalCorp" has 20,000 Contacts, 5,000 Opportunities, and 10,000 Cases associated with it.
- Any updates to "GlobalCorp" can cause significant performance issues due to the large number of related records.
- Changes to the "Account" record trigger sharing recalculations and potential locks on related records.

#kb_sfdc_content
Solution:

- Break down large accounts into multiple smaller accounts if feasible.


- Ensure that related records are distributed evenly across different accounts.
- Use custom indexes and optimize queries to handle large datasets more efficiently.

#kb_sfdc_content
3. Best Practices to Mitigate Data Skew

1. Distribute Data Evenly:


- Avoid assigning a large number of records to a single user or parent record.
- Implement automated processes to distribute records evenly.

2. Use Asynchronous Processes:


- Schedule batch jobs during off-peak hours to handle large data updates.
- Use asynchronous Apex (like @future methods or Queueable Apex) to minimize synchronous processing delays.

#kb_sfdc_content
3. Optimize Sharing Settings:
- Use public read/write groups or roles where possible to minimize sharing recalculations.
- Regularly review and optimize sharing rules to ensure they are not overly complex.

4. Monitor Performance:
- Use Salesforce performance monitoring tools to identify and address data skew issues.
- Regularly audit data to ensure it is evenly distributed and does not cause skew.

5. Index Critical Fields:


- Ensure that lookup fields and other critical fields are indexed to improve query performance.

#kb_sfdc_content
#kb_sfdc_content

You might also like