Hello all, Has anyone already handled the ability to handle an array of siblings or children with one tree number update? Something like: => children = [ child1.create, child2.create, child3.create ] => parent.add_children(children) which would then renumber the tree once, instead of once for each child? Or: => children.add_all_to_left_of(sibling) ? I am going to be doing updates to a nested set... but usually an array of updates and I was looking to see if this has been done already? Regards Mikel
I''m afraid I haven''t. If your primary concern is performance, and you are adding lots of children to large trees, I think you could get a boost by adding the parent and all the children at the far right of the tree (fewer rows get updated), then moving the parent and children to their proper place in a single operation. Kludgey, though. Krishna On 7/15/07, Mikel Lindsaar <raasdnil at gmail.com> wrote:> Hello all, > > Has anyone already handled the ability to handle an array of siblings > or children with one tree number update? > > Something like: > > => children = [ child1.create, child2.create, child3.create ] > => parent.add_children(children) > > which would then renumber the tree once, instead of once for each child? > > Or: > > => children.add_all_to_left_of(sibling) > > ? > > I am going to be doing updates to a nested set... but usually an array > of updates and I was looking to see if this has been done already? > > Regards > > Mikel > _______________________________________________ > Betternestedset-talk mailing list > Betternestedset-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/betternestedset-talk >
Thanks for the idea... but I came up with a change in database schema that avoids this problem... probably for the best :) Mikel On 7/17/07, Krishna Dole <dontfall at gmail.com> wrote:> I''m afraid I haven''t. If your primary concern is performance, and you > are adding lots of children to large trees, I think you could get a > boost by adding the parent and all the children at the far right of > the tree (fewer rows get updated), then moving the parent and children > to their proper place in a single operation. Kludgey, though. > > Krishna > > On 7/15/07, Mikel Lindsaar <raasdnil at gmail.com> wrote: > > Hello all, > > > > Has anyone already handled the ability to handle an array of siblings > > or children with one tree number update? > > > > Something like: > > > > => children = [ child1.create, child2.create, child3.create ] > > => parent.add_children(children) > > > > which would then renumber the tree once, instead of once for each child? > > > > Or: > > > > => children.add_all_to_left_of(sibling) > > > > ? > > > > I am going to be doing updates to a nested set... but usually an array > > of updates and I was looking to see if this has been done already? > > > > Regards > > > > Mikel > > _______________________________________________ > > Betternestedset-talk mailing list > > Betternestedset-talk at rubyforge.org > > http://rubyforge.org/mailman/listinfo/betternestedset-talk > > > _______________________________________________ > Betternestedset-talk mailing list > Betternestedset-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/betternestedset-talk >