function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Dorian Sutton 9Dorian Sutton 9 

How to remove records deleted from the Recycle Bin?

I've been working on an Org where a very large number (over 20,000) of Contacts have been deleted, then emptied from the Recycle Bin.

The Recycle Bin was emptied several days ago, but the Contacts are still visible with IsDeleted = true with an ALL ROWS SOQL query.

All the Salesforce documentation says is that the time to permanently delete emptied recycle bin records will be 'usually 24 hours but may be longer or shorter'. 

We have raised a Case with Salesforce Support, who suggested using the emptyRecycleBin method, but this has not worked as the Recycle Bin no longer contains the records in question.

Because we are using an ALL ROWS query in another part of our application these deleted records are causing problems - does anybody have any suggestions about how I can remove them?
Dheeraj ChawlaDheeraj Chawla
Hi Dorian,

Its is working fine in my case. I deleted one account record and then click on empty my recycle bin button. then I quried on account object. I can not find my deleted record.
Dorian Sutton 9Dorian Sutton 9
Dheeraj - I don't think you quite understood the problem above.  If you delete a large number of records from the recycle bin at once they are visible in Apex SOQL queries with the 'ALL ROWS' keywords until Salesforce's automatic garbage collection processes get around to permanently deleting them.  Salesforce do not give guarantees about how long this will take, and in our case the records were still visible after a week.

In case anybody needs to know how we sorted this - Salesforce eventually agreed to manually delete the 'ghost' records from their database.  They required that we present them with a detailed business case for doing so, but I should point out that they were very helpful and supportive once we had fully explained the problem.