Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Is there any fastest way to delete the data from User (sys_user) table ?

Vijay Talupula
Tera Guru

Hi All,

I was trying to delete User [sys_user] table data from our DEV instance which has around 20K records.

Version: Istanbul

1) I have tried initially using Back Ground script (forgot to include setWorkflow(false); statement), it had taken 2.30 hrs time for 15K records.

        var gtd = new GlideRecord('sys_user');

        gtd.query();

        gs.print("No. of records in the table = " +gtd.getRowCount());

        gtd.deleteMultiple();

        gs.print("Deleted " + gtd.getRowCount() + " records from 'sys_user' table");

       

2) Later I have tried using the below schedule job (On Demand) but didn't see any much improvement.

        var gtd = new GlideRecord('sys_user');

        gtd.addQuery('active', false);

        gtd.setWorkflow(false);

        gtd.query();

        gs.log("No. of records in the table = " +gtd.getRowCount());

        gtd.deleteMultiple();

        gs.log("Deleted " + gtd.getRowCount() + " records from 'sys_user' table");

Please provide if there are any best and fastest way to delete the bulk data.

Regards,

Vijay

9 REPLIES 9

Hi Vijay,



I think you can simply go for Hi support for your instance.


find_real_file.png


You will get to remove all the demo data from your instance.



Hope this helps.



Please hit Like or mark Helpful or Correct based on the impact.



Thanks,


Rajshekhar Paul


Hi Rajshekhar,



Thanks for your response. Did you ever try this option ? If so, how much time it had taken to remove the data ?


Hi Vijay,



I had a chance long back to do such work. It might take 4-5 hours to clear out the data from your instance.


Also you can refer to this below helpful community article:



Remove Demo Data from your Instance without submitting an Incident



Hope this helps.



Please hit Like or mark Helpful or Correct based on the impact.



Thanks,


Rajshekhar Paul


Hi Rajashekar,



Thanks for providing the info. I think this process/HI support request is to remove only Demo data.



But I am looking to remove the data which we have loaded earlier in the system and as part of correction, wanted to delete the old one and load Fresh data.



Is this self-service request will do such kind of removals ?



Regards,


Vijay


Hi Vijay,



Okay, I got your point.


I find no other way than to use a background script to achieve this.


It's a time consuming thing. Some times, I also need to delete CI's, and I also follow the same technique which actually takes time to get accomplished.



You can refer to this links once:



Background Scripts — ServiceNow Elite


http://wiki.servicenow.com/index.php?title=Remove_All_Data_from_a_Table#gsc.tab=0



Hope this helps.



Please hit Like or mark Helpful or Correct based on the impact.



Thanks,


Rajshekhar Paul