Deleting older or unwanted records in Data Management Console
Summarize
Summary of Deleting Older or Unwanted Records in Data Management Console
The Data Management Console in ServiceNow enables automatic deletion of older, expired, or unwanted records from core and custom tables using table cleanup rules. This feature helps maintain database hygiene by removing inactive records, improving system performance and storage management.
Show less
Predefined table cleanup rules exist in the base system and can be viewed in the Auto Flush [sysautoflush] table. Additionally, data management policies related to these rules can be accessed via the Data Management Policies module.
Key Features
- Automatic Scheduled Cleanup: The table cleaner scheduled job runs hourly by default, executing queries defined in cleanup rules to delete records.
- Rule Management: Cleanup rules are listed in the Auto Flush table and can be managed or extended for different tables, including core and custom ones.
- Performance Considerations: Query efficiency is critical; indexed fields should be used in conditions to avoid slow processing. If a cleanup rule's query exceeds 30 seconds, the job stops and retries the rule after a default two-day wait, configurable via system properties.
- Disabling Cleanup: Administrators can disable cleanup on specific tables by adding the "Disable Table Cleaner" attribute in the table’s dictionary, preventing rule creation or execution.
- Limitations: Cleanup rules support extension and shard tables but do not support tables configured with table rotation. Legacy rules may exist on some tables but can be ignored safely.
- Deletion Behavior: Table cleaner deletes records without triggering business rules, workflows, or flows since DBDelete objects run with workflow=false. This must be considered if record deletion logic relies on these automations.
Practical Implications for ServiceNow Customers
- Use table cleanup rules to automate housekeeping of large tables, especially for inactive or expired records, to optimize instance performance and storage.
- Ensure that cleanup rule queries are optimized with indexes on key fields to prevent slow execution or job failures.
- Review and manage data management policies to tailor cleanup behavior for specific tables, including custom tables created on the ServiceNow AI Platform.
- Consider the impact of disabled workflows on record deletion and plan for alternative mechanisms if business logic depends on triggers during deletion.
- Be aware of limitations around table rotation and legacy rules to avoid unexpected behavior or unsupported configurations.
Delete older, expired, or unwanted records from tables automatically.
Delete older, inactive records in core tables such as the Task [task] table and records in custom tables that you create on the ServiceNow AI Platform using table cleanup rules.
- You can view a list of all the table cleaner rules in the Auto Flush [sys_auto_flush] table by entering sys_auto_flush.list in the filter navigator. The Auto Flush table displays rules for base system tables and their corresponding record ages.
- You can view a list of table cleaner rules defined on a single table by navigating to and selecting the data management policy record for the table, if it exists. The system automatically creates a data management policy record for any table that has an archive rule or table cleaner rule.
Slow rule handling
The table cleaner scheduled job runs once per hour (by default). When the table cleaner job runs, each table cleaner rule runs several queries as part of the process. If there's no index on a rule's match field or on significant portions of its condition, rule processing can be slow because its queries are running inefficiently on large amounts of data.
If a table cleaner rule has a query that takes longer than 30 seconds to complete, the entire table cleaner job is stopped. By default, table cleaner waits two days before including that rule in the table cleaner job again, which enables the table cleaner job to run without disruption in the meantime. You can configure the duration of the waiting period by adding a system property. See Table cleaner properties.
Disabling table cleanup
You can prevent an administrator from creating a table cleanup rule or running the table cleaner on a specific table by adding the Disable Table Cleaner attribute to the table's dictionary record. Some internal system tables have the Disable Table Cleaner attribute added by default.
Table cleanup limitations
- As of Xanadu patch 5, table cleaner rules defined in the Auto Flush [sys_auto_flush] table are supported for extension and shard tables. However, table cleaner rules aren't supported for tables configured with table
rotation.
When using the GlideTableCleaner scriptable directly, table cleaner rules aren’t supported for tables configured with table rotation or table extension. Some tables in your instance might have legacy table cleaner rules that were established before table rotation was enabled. These legacy rules can be safely ignored.
- Performance depends on the size of the table and the conditions that you specify. For example, if you use a custom column without an index in a large table, performance is severely degraded. Performance also depends on the number of rows to be deleted.
- Table cleaner spends a maximum of 20 minutes to delete records from a single table. If queries are slow, the volume of records deleted in the 20-minute period may be small.
- Table cleaner doesn't call
DBDelete.setWorkflow(). This meansDBDeleteobjects run withworkflow=false(false is the default value for a Java Boolean). As a result, business rules, workflows, and flows that you expected to trigger on record deletion won’t trigger in the context of table cleaner. This is important to consider if you have business logic that depends on this type of functionality.