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

Vijay Talupula
Tera Guru
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

Alikutty A
Tera Sage

Hi,



The process of deletion takes time on the database when done using scripts. It will take the same time as you delete records manually on UI. I believe the fastest way to delete is performing it at the database level using SQL queries which can be done by SN.



Thanks


Please Hit like, Helpful or Correct depending on the impact of the response


Hi Alikutty,



So you meant to say that, we need to raise a HI ticket for that ? if So, getting that HI ticket resolved, will also takes the same time I guess.



What do you say ?



Regards,


Vijay


You need to decide on which is better  



Which version are your running? Try running this query in Background scripts.



gs.sql("delete * from sys_user;");



gs.sql was removed in later versions, you can run SQL queries using it.



Also please read GQL (Glide Query Language) Part 1: The Concept



Thanks


Please Hit like, Helpful or Correct depending on the impact of the response


It is Istanbul .