Reparenting large number of domains
This article provides recommendations and describes considerations before updating parent domains, which affect a large number of child domains within the hierarchy. Attempts to try to update the parent of thousands of domains and update can take an unreasonably long time to complete or never complete.
Keep in mind that when you update the parent domain, it changes the domain hierarchy. When the domain hierarchy is updated, the system triggers cascade updates on all domain-aware tables for the records created on that domain. Therefore, keep in mind that it is not just one table being updated but that in the backend you are touching large number of other records too.
Consider looking into these tables during your change.
domain_work_request – Captures information during lengthy operations like changing the domain hierarchy.
For example, when you update the domain hierarchy, this table captures all the information for the tables that are touched. A ;arge number of entries in this table can slow down the domain update. This table is set to clean data that is 30 days old using table cleaner. You can clean up this table more rigorously if needed.
syslog_domain – When the domain hierarchy is updated, the system triggers a scheduled job to recalculate domain paths. The result of the job is captured in the domain logs table:
Always test such changes on a subproduction instance that has been recently cloned from a production instance. Be sure to calculate the time it would take for the process to complete and to make sure the correct tables are touched. Always do such changes outside your business hours in production instance, because your updates will run on multiple tables.
Reconsider the need to chage the domain hierarchy. Updating the domain hierarchy is not recommended unless it is absolutely required.
Once the decision has been made to re-parent the domain hierarchy, update/delete domains in batches if working on a large number of domains. Reparent only a few domains at a time. For example, to change the hierarchy of thousands of domains, consider reparenting 100 domains at a time.
Before starting a second batch, make sure DWR records are processed.
In the syslog_domain table, look for the information entry for DWR execution completed.
In domain_work_request, make sure all records have reached State = 3.
Use background script or scheduled job for the update and add some debugging statements to track your transaction logs under System Logs.