- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2026 10:23 PM
hi @Ashwin Perumal1 ,
For 6 million records, I would avoid a single delete operation. The batching approach is correct, but I would process the records in small batches and commit between batches so that one long transaction does not hold locks for too long.
Also, first check whether there are references to these Location records. Deleting 6M records can trigger Business Rules, auditing, Flow/Workflow, reference cleanup, etc., which can be much more expensive than the delete itself.
A common approach is:
var batchSize = 5000;
var gr = new GlideRecord('cmn_location');
gr.addEncodedQuery('YOUR_CONDITION');
gr.orderBy('sys_id');
gr.setLimit(batchSize);
gr.query();
while (gr.next()) {
gr.deleteRecord();
}
For very large volumes, I would run this repeatedly through a Scheduled Script Execution or controlled background process rather than keeping one Fix Script running for hours.
If the records are completely disposable and you have confirmed that you do not need the associated Business Rules/audit processing, you can also evaluate deleteMultiple(), but test carefully because deleting 6M records can have a significant impact on the instance.
Before running in production, I would test with 10K → 100K → 1M records and monitor transaction time, DB load, locks, and related table growth. Also take a backup/restore point if your environment supports it.
If this helps, please mark it as Helpful and accept the solution.
Regards,
Tejas