<h2>Table cleaner</h2><br/><div style="overflow-x:auto"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><meta content="text/html; charset=UTF-8" /><meta name="copyright" content="(C) Copyright 2025" /><meta name="DC.rights.owner" content="(C) Copyright 2025" /><meta name="generator" content="DITA-OT" /><meta name="DC.type" content="concept" /><meta name="DC.title" content="Table cleaner" /><meta name="abstract" content="Table cleaner deletes older records automatically and prevents data from growing exponentially." /><meta name="description" content="Table cleaner deletes older records automatically and prevents data from growing exponentially." /><meta name="DC.relation" scheme="URI" content="../../../administer/managing-data/concept/c_DataManagement.html" /><meta name="DC.relation" scheme="URI" content="../../../administer/general/concept/intro-now-platform-landing.html" /><meta name="DC.relation" scheme="URI" content="../../../administer/general/concept/config-now-platform-core-features.html" /><meta name="DC.relation" scheme="URI" content="../../../administer/general/concept/tables-fields-and-forms.html" /><meta name="DC.relation" scheme="URI" content="../../../administer/managing-data/task/activate-table-cleanup.html" /><meta name="DC.relation" scheme="URI" content="../../../administer/managing-data/reference/table-cleaner-properties.html" /><meta name="DC.creator" content="ServiceNow" /><meta name="DC.date.created" content="2023-08-03" /><meta name="DC.date.modified" content="2024-02-01" /><meta name="DC.format" content="XHTML" /><meta name="DC.identifier" content="table-cleaner" /><link rel="stylesheet" type="text/css" href="../../../CSS/commonltr.css" /><title>Table cleaner</title></head><body id="table-cleaner"> <div class="breadcrumb"><a class="link" href="https://docs.servicenow.com/bundle/washingtondc-platform-administration/page/administer/general/concept/intro-now-platform-landing.html" title="As a platform administrator, you have the power of the ServiceNow AI Platform at your fingertips. The ServiceNow AI Platform is an application platform as a service that automates business processes across the enterprise.">Administer the ServiceNow AI Platform</a> > <a class="link" href="https://docs.servicenow.com/bundle/washingtondc-platform-administration/page/administer/general/concept/config-now-platform-core-features.html" title="The ServiceNow AI Platform provides for a multitude of customization options to your applications. Customize your UI, handle user and data administration, and localize your instance for time zones, currencies, and more.">Configure ServiceNow AI Platform Core Features</a> > <a class="link" href="https://docs.servicenow.com/bundle/washingtondc-platform-administration/page/administer/general/concept/tables-fields-and-forms.html" title="ServiceNow provides options for managing your data on the ServiceNow AI Platform.">ServiceNow AI Platform tables and data</a> > </div> <h1 class="title topictitle1" id="ariaid-title1">Table cleaner</h1> <div class="body conbody"><p class="shortdesc">Table cleaner deletes older records automatically and prevents data from growing exponentially.</p> <p class="p">Table cleaner is a scheduled job that runs once per hour (by default) to delete older, expired, or unwanted records from tables. Table cleaner prevents tables from growing to an unmanageable size and improves query performance.</p> <p class="p">You can view a list of table cleaner rules in the Auto Flush [sys_auto_flush] table by typing sys_auto_flush.list in the filter navigator. The Auto Flush table displays rules for base system tables and their corresponding record ages. Multiple rules can appear for a single table if each rule has a unique condition defined.</p> <div class="section" id="table-cleaner__section_ix3_dyp_ktb"><h2 class="title sectiontitle">Which records are deleted</h2> <p class="p">Each table cleaner rule specifies the following:</p> <ul class="ul" id="table-cleaner__ul_x5t_hxq_ktb"><li class="li">The target table (to delete records from).</li><li class="li">A <span class="ph uicontrol">Matchfield</span> value that corresponds to a Date/Time column in the target table. Ideally, the <span class="ph uicontrol">Matchfield</span> is a date field that represents how long the record has been active (for example, sys_created_on) or how long since the last update (sys_updated_on).</li><li class="li">An <span class="ph uicontrol">Age in seconds</span> value that determines when the delete is triggered.</li><li class="li">Options for cleaning related records in peripheral or audit tables. </li><li class="li">One or more optional conditions to filter which records are deleted. For example, you might specify that only records where 'active = false AND state =closed' are deleted.</li></ul> <p class="p">When the <span class="ph uicontrol">Matchfield</span> date is farther in the past than the <span class="ph uicontrol">Age in seconds</span> value, the table cleaner job deletes the record.</p> </div> <div class="section" id="table-cleaner__section_myk_cly_mxb"><h2 class="title sectiontitle">Slow rule handling</h2> <p class="p">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.</p> <p class="p">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 <a class="xref" href="https://docs.servicenow.com/bundle/washingtondc-platform-administration/page/administer/managing-data/reference/table-cleaner-properties.html" title="These system properties control table cleaner behavior.">Table cleaner properties</a>.</p> </div> <div class="section" id="table-cleaner__section_ypj_qsv_szb"><h2 class="title sectiontitle">Disabling table cleaner</h2> <p class="p">You can prevent an administrator from creating a table cleaner 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.</p> </div> <div class="section" id="table-cleaner__section_fgd_xwp_ktb"><h2 class="title sectiontitle">Table cleaner limitations</h2> <p class="p">Note the following limitations.</p> <ul class="ul" id="table-cleaner__ul_gvk_gxp_ktb"><li class="li">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 or table extension were enabled. These legacy rules can be safely ignored.</li><li class="li">Performance depends on the size of the table and the conditions 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.</li><li class="li">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.</li><li class="li">Table cleaner does not call <code class="ph codeph">DBDelete.setWorkflow()</code>. This means <code class="ph codeph">DBDelete</code> objects run with <code class="ph codeph">workflow=false</code> (false is the default value for a Java Boolean), hence Delete business rules and workflows are not triggered.</li></ul> </div> </div> <div class="related-links"> <ul class="ullinks"><li class="link ulchildlink"><strong><a href="https://docs.servicenow.com/bundle/washingtondc-platform-administration/page/administer/managing-data/task/activate-table-cleanup.html">Activate table cleanup</a></strong><br /> Activate table cleanup for tables with older, expired, or unwanted records.</li><li class="link ulchildlink"><strong><a href="https://docs.servicenow.com/bundle/washingtondc-platform-administration/page/administer/managing-data/reference/table-cleaner-properties.html">Table cleaner properties</a></strong><br /> These system properties control table cleaner behavior.</li></ul> <div class="familylinks"> <div class="parentlink"><strong>Parent Topic:</strong> <a class="link" href="https://docs.servicenow.com/bundle/washingtondc-platform-administration/page/administer/managing-data/concept/c_DataManagement.html" title="Data is stored and managed in your instance according to a principled structure that administrators can view and configure. Data management functions include importing, exporting, and archiving database data and configuring fields and tables.">Data management</a></div> </div> </div></body></html></div>