Servicenow scheduled job takes too much time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2018 01:06 PM
I have a Job schedule job running.
The scheduled job checks approx. 4000 records based upon a criteria(events coming from a third party monitoring tool) and almost inserts 1000 records(I know its huge but such is the case) in a table using the scripts.
While the job is scheduled to run every 5 mins, This entire process takes around minimum 10 Mins to finish, which is too much and hence creates delay.
Please note that I have optimized my code to this level of 10 mins and I feel helpless after this.
Questions:
Is it possible to increase the processing capacity from the servers side i.e. Servicenow Side and somehow reduce the processing time to 5 mins?
I might not be knowing if such a feature already exists or I have to write something in the code itself?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2018 01:11 PM
I think the only thing you could do would be to see if you can further optimize your code (or run your scheduled job less frequently). If you can share your code here I could take a look and see if it can be improved.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2018 11:02 PM
Ensure there are no business rules running using setworkflow(false)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2018 11:47 PM
Hi Harish,
Could you please share your code or some sample code similar to your code. Just want to know how your code is checking 4000 records and then inserting 1000 records.
You can use setWorkflow(false) to stop you Business rule(if there are any) from running on every record. I know this is not a good way, but you can do it if that does not impact your data.
Also the question is that if somehow you reduce the processing time to 5 mins then also if the records your code is checking increases in future then again you will come back to this situation, since record count will not always be same.
Thanks