1

I am looking for an official resource or step-by-step instructions to use Bulk API to delete more than a Million of records from a custom object. I couldn't find a proper documentation online and everywhere, I see a simple deletion of one record using URI.

All I did is:

Used SOQL within Workbench (by selecting Bulk CSV) and downloaded the .csv file. Then tried to use Delete operation in the workbench and received some 403 error message due to the size of the csv file. Then I have used Data Loader and performed a delete operation, which worked great, but very time consuming process (took more than 1.5 hours for deleting 1.2M records).

So, looking for a simple REST solution which could possibly decrease the time and runs in Bulk API context. Any insights are welcome.

1 Answer 1

2

What you're already doing is structurally the correct approach to delete a large volume of sObject records:

  • Extract the data to be deleted (just the Ids).
  • Load the data into a Bulk API delete job.
  • Wait.

The one key thing I don't see in your post is whether the Data Loader is actually configured to use the Bulk API. It can use either Bulk or SOAP APIs. The documentation describes how to configure the Bulk API:

  1. Open the Data Loader.
  2. Choose Settings | Settings.
  3. Select the Use Bulk API option.
  4. Click OK.

The Bulk API for large data sets should be substantially faster than the SOAP or REST APIs.

You may encounter issues with row locking when running the Bulk API in parallel mode, which is the default. That matters a lot less when doing deletes; the easiest fix is likely just to run a second delete job in serial mode with any records that failed.

1
  • I periodically have issues getting Data Loader to work, so I prefer to use the Salesforce CLI. I just fed it a CSV with over 1M rows using sfdx force:data:bulk:delete, and it ran pretty efficiently. See developer.salesforce.com/docs/… Jan 7, 2022 at 20:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .