- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2017 01:12 PM
We have a new sub-prod instance that has been cloned from prod, but there is a request to removed 11 yrs of history from this instance. I have a BG Script running but its taking an hour to delete 100 records. I have over 2m records to remove. Any thoughts or scripts to quickly wipe out all records on a table? Here's what I'm running.
var rec = new GlideRecord('incident');
rec.query();
while (rec.next()) {
gs.print('Inactive incident ' + rec.number + ' deleted');
rec.deleteRecord();
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2017 06:40 AM
In working with ServiceNow, here is the option they suggested I try:
Navigate: Automated Test Framework > Administration > Table Cleanup
- Click New
- Tablename: <table to delete records>
- Age in seconds: 1 day's worth of seconds (60x60x24 = 86400) or a week or whatever you want to keep
- Cascade delete: true (that way it will clean up other data)
- Then there are more conditions you can add.
- Click Submit
Let the scheduled job Table Cleaner run it's schedule. To check and verify there is a scheduled job.
Navigate: System Scheduler > Scheduled Jobs
- Search Name: Table Cleaner
*Note the Next Action Date/Time
If the scheduled job does not exist - create a new job to repeat every hour, but this is an OOB job and should exist.
Once the scheduled job has run and completed - DELETE THE TABLE CLEANUP you created. If not, you will continually delete the records from the table.
I was able to delete 1.8m records in about 6 hours.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2019 04:39 PM
Table Cleaner does not appear to be usable for just any table. I tried to use it to delete data from cmdb_ci and some other tables and they would not show up in the dropdown?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2019 05:11 PM
Hello,
The KB explains various option to work with mass data deletions.
Mass-Deletion and Excess Data Management Guide ==>KB0717791
It also discuss pros and cons on various approaches as well.
Thanks,
Dipu Joy