deletemultiple() takes too long

Jags5
Mega Sage

I am using deleteMultiple() command in a fix script to delete unwanted records.

I have nearly 200 K records in Group Member table which I don't need.

I created a fix script. The Fix Script takes forever to complete.

On an average it is deleting 1000 records in 5 minutes. Is this expected or am I doing something wrong?

Here is my Script:

var grpMembers = new GlideRecord('sys_user_grmember');
grpMembers.addQuery('user.name', grUsersEmptyGroups.getValue('u_username'));
grpMembers.addQuery('group.name', '');
grpMembers.setWorkflow(false);
grpMembers.deleteMultiple();

----

grUsersEmptyGroups.getValue('u_username') I am passing from an outer query which is basically a user name.

Let me know how to improve my query and delete records quicker.

Thanks 

7 REPLIES 7

Jaspal Singh
Mega Patron
Mega Patron

Hi,

 

That is expected as the table you are deleting from is Group-Membership which when deleted has to revokes roles as well & if the count is huge there should be some delay. Better schedule a schedule job to take care of it rather than using background script & waiting for completion.

Thanks Jaspal for the quick response. The scheduled job would still take the same time is it?

Only that we wont be waiting on it to complete.

How abt using deleterecord command instead of deletemultiple?

Hi,

As Jaspal mentioned, it's expected to take time. 

The scheduled job will take the same time but the advantage is you can set the time as non business hours for example 01:00am. So it will not impact the system performance.

I believe deletemultiple will be the best option for you since, you are deleting huge number of records

Regards,

Alok

Yes, we cannot be sure about time difference but this would ensure activity happens in the backend & there is no wait time.

Also, prefer deleteMultiple() for bulk deletion. Also, if required, I strongly recommend you to go through link that has detailed scenarios covered for deletion.