- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2022 07:54 PM
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?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2022 01:21 AM
Yuki,
Check Mwatkins's reply in the following thread.
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.
Following Now Support page has instructions on how to use table cleaner.
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0694151
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2022 12:17 AM
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.