Cleaning up transformed rows right after transform completion

nikita_mironov
Kilo Guru

Hi
Hope it will be useful for somebody.
We have faced a situation that after running Service-Now for several months several import set tables had grown to unmanageable size. Those tables were used for huge data uploads that happened _every_ day.

 

My first idea was to enable Scheduled Import Sets Cleanup (see http://wiki.service-now.com/index.php?title=Import_Set_Scheduled_Cleanup).
This solves the issue but puts a constraint. The scheduled cleanup is enabled for _all_ import set tables. You can not specify that certain import set table (e.g. some integration or other important things) is not cleaned up according to different schedule than other less important import set table that consumes a lot of DB storage.

 

Here is "OnComplete" Transform Map script (see http://wiki.service-now.com/index.php?title=Transform_Map_Scripts) that runs at the end of an import run, after all data rows are read and transformed. It simply deletes all import set rows that have been just transformed. The Transform Map Script uses "import_set" object available for "OnComplete" Transform Map script and out of the box Script Include "ImportSetCleaner" (with no customization). I find it very useful when you are processing thousands/millions of records and do not expect the necessity of troubleshooting, so you can drop them immediately after processing (import set, import set history are kept in the system by the way, only import set rows are dropped):

 

/**
* Delete import set rows on transform completion
**/
var ic = new ImportSetCleaner();
ic._cleanTable(import_set.table_name, 'sys_import_set=' + import_set.sys_id);

 

Of course, Scheduled Cleanup (http://wiki.service-now.com/index.php?title=Import_Set_Scheduled_Cleanup) should be enabled anyway, but like in my case it can be scheduled to clean import sets older than XX days while huge import sets are emptied from rows immediately.

 

Attached is the screenshot illustrating the implementation.

 

Any comments/suggestions are welcome.

 

P.S. Read carefully http://wiki.service-now.com/index.php?title=Import_Set_Scheduled_Cleanup before you proceed with scheduled cleanup setup - you may need to get in touch with Customer Support if your sys_import_set_row table contains too many rows.

 

Message was edited by: Lawrence Eng Missing screenshot re-attached.

9 REPLIES 9

lawrence_eng
Administrator
Administrator

Thank you for sharing this!


chr_kluge
ServiceNow Employee
ServiceNow Employee

Hi Nikita



Thanks for this. That's exactly what I'm looking for.


I don't need it - it works fine.


But can you tell me where the screenshot is?



CU


Christina


Hi Christina,



When we migrated from one community platform to another, it looks like the screenshot got lost. I will try to find it for you.



best,


Lawrence


Hi Christina,



The screenshot is attached now.