ClosureTree/closure_tree

How can I migrate 3 million data to hierarchy table?

shawndodo opened this issue · 0 comments

Hi all,
I want to add has_closure_tree to a model A having 3 million data, and I also want to create the initial data for model A's old data in hierarchy table. I think if I just use A.rebuild! with one sidekiq job, my db and system may be not able to withstand the impact. Then I tried to generate 500 records with each job to get the actual execution time. But I found that a job took an average of 6 minutes. Do you have any suggestions? Or whether I can only upgrade my db? Thank you.