0

I want to delete 10 million records from the custom object. How to delete all records without batch class and within minimum time.

1
  • 1
    Hi and welcome to SFSE. Please read How to Ask then edit your question to state what you've tried/researched so far and where you are stuck. As it stands, this question is likely to get closed without answer since this isn't a free coding service. I would also say that this feels somewhat like an interview question given that it excludes the most obvious solution approach.
    – Phil W
    Jun 9, 2022 at 11:16

3 Answers 3

3

You can able to delete the custom object records by using Truncating feature without using apex code.

If you do not see Truncate button in the custom object, go to Setup | Customize | User Interface | Enable Custom Object Truncate

Truncating custom objects allows you to delete all of the object’s records permanently, but preserve the empty object and its metadata.

Truncating custom objects is a way to permanently remove all of the records from a custom object, while keeping the object and its metadata intact for future use. Truncating is useful, for example, if you have created a custom object and filled it with test records. When you’re done with the test data, you can truncate the object to purge the test records, but keep the object and put it into production. This is much faster than batch-deleting records and possibly recreating the object.

  1. Go to the object management settings for custom objects.
  2. Click an object name to go to the object’s detail page, and then click Truncate.
  3. In the Confirm Custom Object Truncate window, review the warning and then enter the name of the object to truncate in the empty field.
  4. Click Truncate.

Refer the help article before proceeding with truncating feature.

0

You could also use SF dataloader to do this

1
  • Though with 10 million records, it would not be a fast operation by any stretch of the imagination. I'd expect that to take on the order of days to complete.
    – Derek F
    Jan 9, 2023 at 23:32
0

Since I don't have the reputation points to comment on Ankaiah's answer, I'll append to his/her answer here.

There are limits to the truncate records of a custom object. This page was helpful in understanding why I could not get the truncate button to show on my custom object.

https://help.salesforce.com/s/articleView?id=sf.dev_object_trunc_overview.htm&type=5

To save click throughs, here is a list of the restrictions:

Are referenced by another object through a lookup field or that are on the master side of a master-detail relationship

Are referenced in a reporting snapshot

Have a custom index or an external ID

Have activated skinny tables

In addition, you can’t truncate custom objects when your org has reached its limit on allowed custom objects.

One last note. If you are not restricted and do not see the truncate button, Ankaiah is correct, check the Enable Custom Object Truncate box; however, the navigation to this is Setup --> User Interface --> User Interface

Yes, it's User Interface under User Interface.

You must log in to answer this question.

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