What is the best way to remove unnecessary data from sys_audit

GLewis5
Tera Guru

In our instance, there were a lot of custom tables added in the past and a lot of custom columns added to out-of-box tables. Most of these custom tables and columns were, unfortunately and unnecessarily, audited. As a result, sys_audit has grown to nearly a billion rows. Much of the data in sys_audit is useless clutter. However, other historical data in sys_audit is important to retain. 

 

Because of the table size, queries on unindexed fields such as tablename or fieldname will time-out and not return a result. What is the best way to get rid of the junk so that we can run queries on the stuff we care about?

 

If I run a Fix Script that does a Glide Query on sys_audit that returns a million rows, and try to do a deleteMultiple, what will happen? Is this even a good idea?

 

1 REPLY 1

Trey3
Tera Contributor

On other tables, my experience has been that the deletion will timeout unless you change a system setting.  I believe the default was 10 minutes but I can't remember exactly.  We limit how many records are deleted at any one time in the script and we try to run when the system is not utilized heavily.  Something similar to below...

Set variable against new GlideRecord ('table');

<variablename>.orderByDesc('name');

<variablename>.setLimit(100);

<variablename>.query();

<variablename>.deleteMultiple();