You inherit a Salesforce org. Documentation is thin and the complaints are stacking up: slow page loads, locking errors, sharing recalculations that never finish. You dig in and there it is, data skew that has been accumulating for years and is now hurting badly.
Most writing about skew covers preventing it while the org is still being designed. This is the other situation, where the skew is already in production and it is yours now. How to find it, size it, decide what to fix first, and fix it without creating a new problem.
Understanding data skew
Skew happens when too many records hang off a single parent record, a single owner (user or queue), or a single record referenced through a lookup field. The concentration is what produces the bottleneck.
There are three primary types:
- Account data skew. Thousands of child records (Contacts, Opportunities, Cases and so on) linked to a single Account. It causes record locking during DML and wrecks bulk data loads.
- Ownership skew. A single user or queue owns a disproportionate share of an object's records. Under a private sharing model, changing that owner's ownership, role, or territory sets off extensive sharing recalculations.
- Lookup skew. Many records reference the same record through a lookup field. Same contention and locking trouble as account skew.
Symptoms you can actually observe:
UNABLE_TO_LOCK_ROWerrors during data loads.- Sharing recalculations that run for hours.
- Specific record pages loading slowly.
- Integration failures tied to particular records.
- Apex batch jobs timing out on queries.
Plenty of performance problems that look unrelated turn out to share this root cause.
Step 1: Diagnose and quantify skew
You need the scope before you touch anything. The numbers are also what buys you prioritization and stakeholder support.
Detecting account data skew
SOQL in the Developer Console or Workbench gets you there:
SELECT AccountId, COUNT(Id) childCount FROM Contact GROUP BY AccountId ORDER BY childCount DESC LIMIT 20
Run the same shape of query against Opportunities, Cases, and any custom object with a lookup or master-detail relationship to Account. Salesforce generally treats 10,000 child records per parent as the threshold where performance problems can appear, with anything over 50,000 being critical.
Detecting ownership skew
Query the ownership distribution:
SELECT OwnerId, COUNT(Id) recordCount FROM Opportunity GROUP BY OwnerId ORDER BY recordCount DESC LIMIT 20
Pay attention to system integration users, queues, and whichever user your automated processes run as. A single user or queue owning over 10,000 records in a private or controlled sharing model is ownership skew.
Checking for sharing recalculation delays
Go to Setup > Defer Sharing Calculations. If somebody keeps switching it on, you have recurring recalculation trouble, and the Setup Audit Trail will tell you how often it has been toggled.
Then check Setup > Background Jobs for sharing recalculation jobs that are long-running or stalled. Anything past a few hours needs attention now.
Step 2: Prioritize remediation efforts
Resist the urge to fix all of it immediately. Sort by business impact and by how risky the fix itself is.
Fix first: skew actively throwing production errors, so UNABLE_TO_LOCK_ROW, stuck sharing recalculations, reports timing out. Those carry consequences you can measure.
Fix next: ownership skew on users about to be deactivated, moved to another role, or handed different territories. Each is a trigger waiting to set off an org-wide sharing recalculation.
Monitor and document: skew that exists and is not currently causing problems. Log it, write down a threshold, revisit on a schedule (quarterly works). Not every instance of skew needs intervention today.
Step 3: Secure leadership buy-in
Fixing skew is invisible, slow, and carries risk, which makes it a hard sell. What gets support:
Translate the errors into cost. "Our nightly sync fails 3-4 times weekly due to locking issues on the Acme account, each requiring 45 minutes of engineering time for a manual re-run."
Use the time bomb framing. "Deactivating or reassigning the integration user will trigger a sharing recalculation on 80,000 records, potentially locking the org for 4-6 hours during business hours."
Tie it to work that is already funded. Skew remediation is risk mitigation for the data migration, the Agentforce rollout, or the new integration that leadership already cares about.
Step 4: Remediation strategies
What works depends on the type of skew and how bad it is.
For account data skew
Split the parent account. For accounts carrying tens of thousands of children, the "Household" and "Global" sort, break them into more granular sub-accounts by region or business unit. It is a data model change and needs stakeholder approval, and it is the fix that holds up long term.
Archive historical records. Bulk archive or soft delete the inactive and old child records. The child count drops a long way without touching the core data model.
Move history into Big Objects. High-volume historical data, closed cases and old activities, goes to Salesforce Big Objects and stops counting toward skew on the standard object.
For ownership skew
Reassign records in batches. Data Loader or a scheduled Flow, run off-peak, in batches of 2,000 records or fewer, so you do not set off a mass sharing recalculation.
Defer sharing calculations deliberately. When a large reassignment is unavoidable, suspend recalculation under Setup > Defer Sharing Calculations, then resume and finish during a scheduled maintenance window. The feature exists for exactly this.
Flatten the role hierarchy. Deep hierarchies make ownership skew hurt more, and flattening narrows the cascade that a role change sets off.
Step 5: Monitor to prevent regression
Skew comes back when nobody is watching for it.
Schedule a monthly SOQL audit. Automate the child-record-count queries with scheduled Apex or a Flow that logs results to a custom object, then build a dashboard tracking top accounts by child count over time.
Set threshold alerts. A Flow or Apex trigger that tells the admin team when account or owner record counts cross a line you picked, say 8,000 child records. Catching it there is far easier than the cleanup later on.
Document what you found and what you did. Keep a change log, in a wiki, Confluence, or a custom object, with the skew you identified, the remediation steps, and the dates. Whoever inherits the org next will need it.
Leave a Comment