The CreatorCon Call for Content is officially open! Get started here.

Deleting all records from large (1TB+) table

Brian Arndt1
Mega Expert

We have a table in our production instance with over 1TB of data in it (1118168054 rows). I'm looking for guidance on the best way to purge this table without affecting system performance. I do not believe there is any reason to retain these records and no new records are being added to it. Would archiving (and destroying) be the most effective, or would it take too long or cause performance issues?

1 ACCEPTED SOLUTION

Brian Arndt1
Mega Expert

Thanks all for the replies but I think the correct answer is submit a case with ServiceNow Support. They can truncate the table in seconds.

View solution in original post

10 REPLIES 10

rajesh9885
Mega Guru

you can do it 2 ways

open the result list--> right click on header of list--> confgure--> table-- click on delete all record button

 

or you can do it in phase likecreated in last 3 month or 6 months

below script can be run on scripts background

var gr = new GlideRecord('<you table name>');

gr.addEncodedQuery(<condition/query>);

gr.query();

gr.next();

gr.deleteMultiple();

Hi rajesh9885,

Thanks for the reply. I understand how to delete records through the UI and with scripting, I just want to make sure it is done responsibly. I can't even open the list because there are too many records.

thats why i said delete record in phase of 3 months

Before using deleteMultiple() it's not a good practice to use the query() and/or next() functions (the deleteMultiple will do the query so we don't need to use those 2 functions) 😉