---
sourceDocument: Brazil Security Management
sourceDocumentLink: https://www.servicenow.com/docs/r/security-management

 Release :

    - brazil

ft:locale :

    - en-US

ft:publication_title :

    - Brazil Security Management

ft:clusterId :

    - security

bundleId :

    - security

workflow :

    - Technology


---

# Steps to help prevent duplicate or orphaned records after running lookup rules

# Steps to help prevent duplicate or orphaned records after running lookup rules {#ariaid-title1}

Release version: Brazil  
Updated September 10, 2026  
![](https://www.servicenow.com/docs/portal-asset/ico-clock) 2 minutes to read
Summarize  
![AI sparkle icon](https://servicenow.com/docs/portal-asset/ai-sparkle-icon) Summarized using AI  
This content was generated using new OpenAI-powered functionality. Results are provided on an as is basis and are not guaranteed to be accurate or complete.  

## Summary of Steps to help prevent duplicate or orphaned records after running lookup rules

This guidance helps ServiceNow customers avoid duplicate or orphaned Configuration Item (CI) records when running lookup rules that match CIs within the CMDB.
Improperly constructed rules and unoptimized matching logic can cause performance issues and data inconsistencies.
Careful testing, analysis, and data clean-up steps are essential to ensure accurate CI matching and maintain CMDB integrity.
Show full answer Show less  

## Key Practices to Avoid Duplicate or Orphaned Records

* **Test with targeted data:** Use small, specific subsets of data relevant to the lookup rule under test while disabling other lookup rules to isolate behavior.
* **Analyze matched CIs:** Review the ratio of matched versus unmatched CIs beyond just the initial imported records. Manually verify sample CIs for correct matching and naming consistency. Adjust matching rules as needed.
* **Review unmatched CIs:** Examine unmatched CIs grouped by class to identify anomalies, such as unexpected CI classes or incorrect classification. Decide if certain classes should be excluded or reclassified.
* **Check CI states:** Identify CIs in states like Retired that may affect matching results.

## Data Cleanup and Retesting

Once matching behaves as expected, clean up test data by deleting imported records from related tables such as Discovered Items, Vulnerable Items, and Remediation Tasks. Then rerun all CI matching rules manually to validate the final configuration.

## Deleting Data from Tables

If imported data errors occur, especially in development or test environments, data deletion may be necessary. Options include:

* Using the "Delete All Records" action in Table Configuration.
* Configuring the Table Cleaner through Auto Flushes.
* Running background scripts with `gs.truncateTable` after disabling rollback to efficiently clear tables.

**Important:** Never use `truncateTable` in production. Large deletions in production or shared environments must be coordinated with ServiceNow Support and require expertise.

## Additional Resources

Refer to the ServiceNow knowledge base articles KB0750656 for lookup rules and Qualys integration, and KB0818096 for lookup rules and Rapid7 integration for more detailed information.  
Take steps to help prevent duplicate or orphan records resulting from matching (configuration items (CIs) within the CMDB.

If rules aren't carefully constructed, importing security exposure data can be taxing on an instance and performance issues with resources can occur. The logic used to iterate through and perform matching within the CMDB can result in lengthy processing times. Thorough testing and debugging of processing scripts in the rules helps alleviate the potential of issues later in the process.

## Avoid duplicate or orphaned records {#sem-ci-identifier-rules-impl-test__section_mzc_n5b_blb}

* Use small subsets of data that are specific to the lookup rule being tested.
  * Set all lookup rules, other than the one being tested, to inactive.
  * Analyze the imported CIs to ensure that you're observing the expected behavior and matching is occurring properly.
  {#sem-ci-identifier-rules-impl-test__ul_ktt_grb_blb}
* Review matched CIs
  * Examine the count of matched vs unmatched CIs. Ensure that the percentage is acceptable. Don't look at the first page that is likely the first one inserted.
  * Manually search for some CIs.
  * Check to see if there are any naming or field problems (such as searching for a specific domain).If it seems appropriate, add additional matching rules.

  {#sem-ci-identifier-rules-impl-test__ul_u14_krb_blb}
* Review Unmatched CIs
  * Navigate to the Unmatched CIs table.
  * Group by Configuration Item class.
  * Review any classes that don't look right (certificates, network cards, images).
    * Figure out why didn't they match the correct CI?
    * Should the class be excluded?
    * Should the class be elevated to a related class?
    {#sem-ci-identifier-rules-impl-test__ul_z5m_trb_blb}
  {#sem-ci-identifier-rules-impl-test__ul_x14_krb_blb}
* Review CI states such as Retired.
* Remove Test Data
  * Once you begin to observe the correct or expected behavior in CI matching, start over.
  * Start over by: Deleting the data used for testing: (see the Deleting data from tables section)
    * Discovered Items
    * Vulnerable Items
    * Remediation tasks
    {#sem-ci-identifier-rules-impl-test__ul_db4_krb_blb}
  * Manually rerunning all the CI Matching rules.
  {#sem-ci-identifier-rules-impl-test__ul_udl_1sb_blb}
{#sem-ci-identifier-rules-impl-test__ul_skp_2rb_blb}

For more information on lookup rules and Qualys, see the [KB0750656](https://support.servicenow.com/kb_view.do?sysparm_article=KB0750656) article.

For more information on lookup rules and Rapid7, see the [KB0818096](https://support.servicenow.com/kb_view.do?sysparm_article=KB0818096).

## Deleting data from tables {#sem-ci-identifier-rules-impl-test__section_ojh_r5b_blb}

Sometimes you have imported data and realize something is wrong. If something is wrong in a development or performance environment, you could reclone from a better environment, but that isn't always an option.  
Note:  
Performing these actions requires ServiceNow expertise.  
There are four options for deleting data from tables:

* Using Delete All Records on Table Configuration.
* Configure the Table Cleaner by navigating to Auto Flushes (sys_auto_flush.list) and creating a Auto-flush record.
* Truncate the gs.truncateTable using a background script. Using truncateTable requires turning off the record for rollback check box in the background scripts. Otherwise, a copy of the table and
  related cascade tables are created, take too long, and most likely fail.

  Note:  
  Never use truncateTable in a production environment. Consult you Support representative before executing large deletions in production or shared environments.
{#sem-ci-identifier-rules-impl-test__ul_swj_vsb_blb}

