closure_tree
closure_tree copied to clipboard
is it possible to only use deterministic order where parent_id is not null?
Hello!
I'm looking at using closure_tree on a table with 4 million rows, I want to use a deterministic integer order but only where the record has a parent. Is that possible?
Right now it seems to be trying to put a sequence over all the records in the table, which is taking too long.
I've just tried
def reorder_with_parent_id(parent_id, minimum_sort_order_value = nil)
return if parent_id.nil?
Which seems to avoid the issue. Should I try to make this a config option?
@robguthrie So does this mean your roots have nil rank? Or do you set them to default to 0 or 1 or something?
Did you make any progress adding this as a config option?