closure_tree icon indicating copy to clipboard operation
closure_tree copied to clipboard

Fast rebuild!, milions rows

Open fernandocchaves opened this issue 6 years ago • 4 comments

Hi I have a system and i need migrate some functions, I have one table with parent_id and a need use this gem, but on run rebuild! in "rails c", took over 24 hours and still not finished.

Exists another way of run it very fast?

fernandocchaves avatar Sep 08 '18 04:09 fernandocchaves

You can do it with SQL directly on the database.

seuros avatar Sep 23 '18 22:09 seuros

@seuros I try create the script, but a don't understand how mount these.

fernandocchaves avatar Sep 24 '18 11:09 fernandocchaves

Is it safe to only run rebuild on items that are part of a tree? I have millions of items and only some of them are in a tree.

It looks like the only consequence of not doing this is that running self_and_descendants and self_and_ancestors will return an empty set. Is that right?

i2chris avatar Sep 09 '20 17:09 i2chris

Have you tried https://github.com/gzigzigzeo/pg_closure_tree_rebuild? It's a significantly faster rebuild.

tgodfrey avatar Nov 17 '20 02:11 tgodfrey