Cascade delete in table cleanup
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2024 01:49 AM
what is ServiceNow best practice to configure table cleanup record for a particular table.
Shall I use cascade delete on parent table or create new auto flush item for child table?
I see when I am using cascade delete it takes longer time to delete the records so I am skipping it, but want to know what is ServiceNow's best practice regarding this.
Please help me ..!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2024 03:43 AM
Hi @Bharat Tagad,
The best practice of cleaning up records in a particular table depends on the context and requirements. You can select from below:
Cascade Delete:
- Use cascade delete if you need to ensure that all related child records are deleted automatically when a parent record is deleted.
- This is ideal for maintaining referential integrity, but it can be slower for large data sets due to the need to process all related records.
Auto Flush (Scheduled Job):
- Create a scheduled job (auto flush) for the child table if you need more control over the cleanup process.
- This method allows you to delete records during off-peak hours, reducing performance impact.
- You can create a script to identify and delete orphaned child records or records older than a certain period.
Recommended Approach:
- Combination Approach:
- For optimal performance and maintainability, use a combination of both methods. Implement cascade delete for critical relationships to ensure data integrity. Use scheduled jobs for periodic cleanup of larger datasets to manage performance efficiently.
- Performance Considerations:
- Regularly monitor and optimize the scheduled jobs to ensure they do not impact system performance.
- Index the columns involved in the delete operations to improve performance.
You can implement this by:
Enable Cascade Delete:
- Navigate to the parent table definition.
- Set the "Cascade Delete" option for the related child tables.
Create Scheduled Job:
- Navigate to System Definition > Scheduled Jobs.
- Create a new scheduled job to run a script that deletes records from the child table based on specific criteria
By balancing these approaches, you can maintain data integrity while optimizing performance.
Also, you can go through the below ServiceNow documentation
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0717791
Please mark it helpful and try to give it a thumbs up if the above helps. Please accept the solution.
Thanks & Regards
Tabassum Sultana