What is the fastest way to delete 1000000 records in cmdb (incl cascade deletes) ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2015 05:23 AM
However some records should NOT be deleted?
Using a background script and deleting with deleteMultiple() runs 20 minutes to delete 100 records! It must be possible to do that faster even with cascade deletes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2015 12:29 AM
Also, for some reason I prefer to delete rows using deleteRow() since it's my understanding that deleteMultiple() ignores some references to the records (like attachments).
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2015 01:03 AM
If you want to delete all data, then use TRUNCATE sql
1. Go to Background Script ot Fix Script
2. Execute this code: gs.sql( 'TRUNCATE TABLE cmdb_ci' );
Do this will all the tables related to it( for Cascade delete )
This will delete all the record in a second.
Even if you want to delete huge amount of data and preserve some data, you can export the data you want to preserver( Export XML) and the Truncate the wholte table, then re import the XML to get back the preserved data.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2015 01:08 AM
"TRUNCATE" is a bad idea when you have references you need to take care of, as you will be left with lots of orphaned records.
Plus, checking manually all the references is also not something you want to do.
Regards,
Sergiu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2015 10:13 PM
Hi tommyjensen,
It appears you got a good set of recommendations from the community on this thread .
Do you believe we can close this thread by marking the responses as helpful/correct or do you have any further questions we can help with?
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2015 10:57 PM
Yes indeed good suggestions however none that suits my needs.
However after the instance has been moved to an onpremise setup it runs a lot faster.