Background script - Optimisation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2023 06:26 AM
Hello,
This is more of an optimisation question.
we've performed an integration and its brought over 1.6 million records where half are empty records. I've run a background script however its taking a lot of time and sometimes just gives up.
Can this script be optimised to work faster or am I just going to have to wait?
var usr = new GlideRecord('cmdb_ci_spkg');
usr.addNullQuery('name');
usr.query();
usr.deleteMultiple();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2023 07:45 AM
Hi Andrew,
You can consider using the GlideMultipleDelete class. This effectively bypasses all the usual GlideRecord-related mechanisms, including business rules, auditing, engines, etc.
var md = new GlideMultipleDelete(<table name>); md.addQueryString(<encoded query>); md.setAllowCascadeDelete(false); // false is the default value md.execute();
Another alternative is query based on indexed fields if not done already.
Thanks.