CMDB Relationship Cleanup

_bhishek
Tera Guru

Hi All,

 

In CMDB relationship table (cmdb_rel_ci),I have total of 4 Million relationships for which parent is non-operational /retired or child is non-operation/retired .SO we want to clean this data with removing these stale/orphan relationships. Also in for future want to make a automatic process if any parent or child is updated as non-operation /retired ,then respective relationship should be removed .What should be the best practice to deal with this data and Do we have functionality from service now to deal with this clean up process.Please suggest .

13 REPLIES 13

pavani_paluri
Tera Guru

Hi @_bhishek ,

 

One-Time Cleanup of Existing Stale Relationships
You can safely remove relationships where:

Either parent or child CI is in Retired or Non-Operational state
The CI no longer exists (deleted or missing)

Fix Script Option
Use a script that identifies relationships where either CI is retired
Optionally previews the records before deletion
Deletes in chunks to avoid performance issues

 

Automated Cleanup for Future Retirements
Use Business Rules or Flows
Create a Business Rule or Flow Designer logic that:

Triggers when a CI’s install_status changes to Retired or Non-Operational
Queries cmdb_rel_ci for relationships involving that CI
Deletes those relationships

This ensures real-time cleanup and prevents stale data from accumulating.

Use CMDB Health Dashboards

Leverage CMDB Relationship Health to monitor stale or broken relationships
Use CMDB Data Manager to define lifecycle policies for CIs and automate cleanup tasks [servicenow.com]


Avoid Manual Deletion of CIs

Instead of deleting CIs, mark them as Retired
Use cleanup scripts to remove only the relationships, preserving historical CI data for audit or reporting


You Can Use

CMDB Data Manager: Automate lifecycle transitions and cleanup
GlideTableCleaner: For bulk cleanup with minimal performance impact [servicenow.com]
Scheduled Jobs: Run periodic cleanup scripts
Relationship Health Dashboard: Identify and track stale relationships

 

Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Pavani P

@pavani_paluri Thanks for your response and sharing these approaches .Just want to confirm ,do we have any functionality provided from service now to delete relationships of CIs for which parent or child CIs are decommissioned/Retired.

As CMDB data manager is available to delete non- operational CIs like this do we have any functionality to delete configuration item relationships .I could not select cmdb_rel_ci table in policy of CMDB data manager.

Please suggest .

 

Thanks & regards,

Abhishek

@pavani_paluri Is there any further suggestions for me .Any input would be helpful here. Thank you.

Hi @_bhishek ,

 

ServiceNow does not have a built-in feature to automatically delete CI relationships when a CI is retired or decommissioned.

CMDB Data Manager can delete or clean up CIs, but it cannot be used for relationships.

That’s why you don’t see the cmdb_rel_ci table available in CMDB Data Manager policies.

By default, when a CI is retired, its relationships stay in the system.

If you want to remove those relationships, you have to handle it manually or with custom logic, such as:

A scheduled cleanup job

A script or Flow that removes (or end-dates) relationships where the parent or child CI is retired

Many teams choose to end-date relationships instead of deleting them, so they keep history for reporting and impact analysis

 

Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Pavani P