About deleting a large number of records

bonsai
Mega Sage

※Paris version

 

I want to empty a table with 2 million records.

I tried to delete Records in bulk using "deleteMultiple ()", but the instance freezes and the Records are not deleted.
Is there a limit to the number of items that can be deleted at once?
Also, is there a way to remove it efficiently?

 

1 ACCEPTED SOLUTION

subramanian
ServiceNow Employee
ServiceNow Employee

The below should work for records in excess of 2 million.

deleteMultiple();

 

Having said that if this is a recurring process there are other options in ServiceNow instance that you can explore -  Auto flush for e.g.

View solution in original post

10 REPLIES 10

Alternatively,

You can try with deleting with setworkflow false and deleteMultiple() in batches but run them as a fix script in background as there is a cap on user query and it will time out for sure as there are 2 million records, in the background it will continue to run.

find_real_file.png

-Anurag

I tried running this button, but it froze and the record wasn't deleted.

Then try running in fix script, in background , in batches. Start small, like 10k and see how much time it takes and accordingly go high like 50k -> 100k till where the system performance doesn't get impacted.

-Anurag

subramanian
ServiceNow Employee
ServiceNow Employee

The below should work for records in excess of 2 million.

deleteMultiple();

 

Having said that if this is a recurring process there are other options in ServiceNow instance that you can explore -  Auto flush for e.g.

The contents of ".addQuery" that was set before "deleteMultiple ();" seemed to be incomplete and did not seem to work.
When I executed "deleteMultiple ();" without setting any query, all records disappeared.
It is currently empty.
thank you.