Script to rebuild the ServiceNow table

Yuki21
Tera Expert
Hello.
How do I reconstruct the ServiceNow table in a script?

After executing the deletion script in the following job schedule
I want to add the process of rebuilding the table.

Is it possible to optimize table with ServiceNow script?

find_real_file.png
1 ACCEPTED SOLUTION

Yuki,

Check Mwatkins's reply in the following thread.

https://community.servicenow.com/community?id=community_question&sys_id=60b6c765db1cdbc01dcaf3231f96...

The thread is a little bit old but the following statement should still hold true.

Generally ServiceNow does not expose this layer of database administration because we don't want our customers to have to worry about it. 

Not sure if the followings still hold but may be worth a try.

If you wanted to force reorganization on a certain table you could create a meaningless, hidden, custom field on that table. Then next time you want to reorganize the table you could remove said field.

 

Another way to force a table reorganization is to add an index to the table. Each time an index is added we do the same online alter operation that totally re-creates the table.

Following article by ServiceNow suggests using table cleaner. Check warning about performance before using it on production instance.

https://community.servicenow.com/community?id=community_article&sys_id=f6578d61db502810fb115583ca961...

Following Now Support page has instructions on how to use table cleaner. 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0694151

View solution in original post

10 REPLIES 10

-O-
Kilo Patron
Kilo Patron

It seems to me that you are always deleting old records and only keeping newer ones. If indeed that is the case, there is a feature called "table rotation" which can be configured to do something like that. Have a look @ article Demystifying table rotation, extension, and table cleaner, maybe table rotation of type "Rotated" is what you need.