Skip to main content

Deleting System Jobs returned by attached query

editSubscribe (0) ShareShare
Posted on by 2
I'm working for customer who has more than 6 million failed/completed/canceled system jobs per organization to delete from its CRM 2016 on prem. I have found up an old article which describes how to delete these jobs via SQL - but I don't think this is proper way to do it. Probably it would be better to use bulk deletion job for that. I don't know why article suggests to delete only jobs with statuscodes 30 and 32 but it does not include jobs with statuscode 31. In case we would delete records recommended by pasted article only arround 1 million of record would be deleted, so I was thinking to expand query conditions. The conditions that I would use in query are shown in image bellow:
Sometime it happens on our Clients production that some query locks asyncoperationtbase table and production stops working.
Last time when production stopped worked we found out the query posted bellow could be the problem for locking db table
I would be very grateful for you opinions about cleaning out such a big number of system jobs on production. Is it safe to cleanout all records from pasted query or could it causes some problems on production?
Thank you in advance.