I had been keeping an eye on our Storage Quota and suddenly noticed that we had passed 100%. We don’t store documents on our Salesforce instance — just object data, most of which is imported from our legacy system. Unfortunately, this had been filling up and we exceeded our 1GB quote (20 users).
First, I used Mass Update Anything (available for both Mac and Windows) with a query to find some old data records. I could then delete those records and re-query. Unfortunately, it only processes about 1000 records at a time.
Then, I saw a Custom Object that I could do without. It was taking 80MB, so I deleted the object. Unfortunately, the 80MB remained allocated — perhaps because the Recycle Bin only empties after 30 days, but I’m not sure. Also, Mass Update Anything didn’t like querying that object, so I was stuck.
Then I remembered a post I had read that morning from MK Partners about using the Salesforce System Log window to mass-update some data. Matt had written some quick Apex that executes in the System Log window. So, I modified it to do a mass delete.

Two points to note:
- The
SELECTstatement can only return 1000 records, lest you receive the error “System.QueryException: Inline query has too many rows for direct assignment, use FOR loop“ - The whole Apex block can only use 10,000 query rows (hence the 10x loop)
So, I had to run it a few times to delete all my records. It all worked very well.
Oh, one more point. When a custom object is deleted and brought back to life, it gets renamed (eg my_obj_del__c), so take a look at the object page to find the correct API name.
The Bottom Line
- Apex can execute in the System Log window
- Apex governor limits can be mostly avoided
- It pays to read blogs!
January 9th, 2009 at 11:26 am
Just curious, but was there a reason you chose not to just use Data Loader (which also handles deletes)?
January 9th, 2009 at 11:35 am
>> Just curious, but was there a reason you chose not to just use
>> Data Loader (which also handles deletes)?
There were 80,000 records. To use Data Loader, I imagine I’d have to export to get a list of them, then re-import with the Delete option.
Or is there a simpler way to do it?
September 23rd, 2009 at 6:37 am
Nice work – is there a easier way to monitor file attachment storage – like you see in setup > administration setup > storage usage, current file storage – attachments?
We have purchased extra attachment space for a particular group in our org, and I’d like to monitor this proactively so we know when we go over the limit for this group. I’ve searched app exchange but nothing matches this and Salesforce itself reports there is no way to do it. Yet it’s there in storage usage. Any help would be appreciated.
September 23rd, 2009 at 11:11 am
Mmm, no — couldn’t find any object that reflects storage in use. Looks like it’s something internal to Salesforce only. Worst case you could use a screen-scraping tool like Selenium to check it.
October 8th, 2009 at 8:53 pm
Files,
Regarding monitoring file attachment storage, vote here
http://ideas.salesforce.com/article/show/22288/Reporting_on_Notes__Attachments
July 2nd, 2010 at 11:24 am
[...] Mass Delete via System Log window [...]