Daily script becomes a stuck process with high cpu and memory usage

Can you run recalculate_device_dependencies and monitor the sql queries so we see what it is running? (enable the general_log in mysqld) Or maybe just adding -d to the command might work.