When you are using Salesforce Bulk API to load hundreds of thousands to millions of rows into your Salesforce org there are times when you will see your loading performance impacted. Below are just some quick tips for you to help optimize those data loads and integrations that are critical to your company’s success. Below are the tips that will give you the biggest bang for your buck to increase performance.
Lets first go over quickly what is Salesforce Bulk API. The Bulk API is an interface that is based on REST principals and is optimized for inserting, updating, and deleting large sets of data in your Salesforce Org.
One of the biggest issues that I have encountered when loading extremely large data sets using the Bulk API into Salesforce is performance (Locks and Lock Exceptions) and what can be done to increase performance based on how a Salesforce Org is configured (I always say Salesforce Orgs are like snowflakes everyone is different).
Below are the biggest areas that you can check to get the best performance of your data loads if they are not running optimal:
Master Detail relationships: When your Salesforce object has a master detail relationship with another object, Salesforce will lock the master record to ensure referential integrity when you are upserting a detail record. To increase performance on your loading sort your data by those Master Detail columns on that object so you can minimize how often the detail records are being inserted across your batches.
Rollup Summary Fields: One of the biggest performance gains you can get here is remove any Rollup Summary Fields that you do not need. Salesforce will lock master records so it can update the rollup summary fields values based on the master detail relationship of the object.
Lookup Relationships: When you upsert or delete an object that have certain type of lookup relationship to another Salesforce object, Salesforce will lock the target lookup records for referential integrity. For some performance gains you can sort by those types of lookups so you can decrease the risk of lock exceptions
Triggers: Salesforce triggers can cause many different issues with your data loads and/or integrations. Salesforce will lock records when you are upserting or deleting a object that has one or more triggers that are selecting or updating on the other record you are performing the action on. Some thing you can try is disabling the trigger when loading your data or when your integration is running.
Workflow Rules: Salesforce locks records when workflows rules get triggered on field updates. To get some performance increase try setting your workflow rules to not get fired off when data loads or integrations are running.