[Nitro] OG vs Active Record

Jonathan Buch john at oxyliquit.de
Fri Aug 24 14:00:39 EDT 2007


> I can appreciate the convinience of using adjacencies.   But
> there are as you suggest other criteria.

I never said I'd be using adjacency lists.  ;)

Right now I'm more on the track on materialized path, which
(with help from postgres) has really good performance for all
operations I need and at the same time is conceptually easy.

> Where I work there's a tree of about 38,000 nodes changing a
> few times a day.  The amount of hand-editing that goes on is
> near nil, though the simplicity of adjacencies has been useful
> in debugging.

Yeah, debugging, good example.  Although an extensive test suite
covering all that might be enough of a safety net for relations
and can provide good enough information when stuff goes wrong...

> The simplicity of adjacencies is a much larger factor if your
> tree is small and there are good reasons to take the short-cut
> of manual edits or manual generation.
>The broadest solution would be maintaining the adjacency list
> *alongside* the nested set.   Simply add a parent_id field to
> each node.  You can hand-insert a node, and run a script to
> have the system place it in the nested set.

I think the NestedSets implementation within Og has the parent
saved too.  That could be a starting place for someone who wants
to investigate on that further.

> Alternatively, you can have a utility script that regenerates
> the adjacency list after an insert.

I heard some professionals use that two layer approach.  They
insert/update only the adjacency list, which is quite quick for
some operations.  Then they just regenerate a nested-sets table
with the new information for fast selects.

Too bad I don't have too much experience yet with real life
high-performance stuff with huge databases.  Thanks Robert for
also replying here.  :)


Feel the love

More information about the Nitro-general mailing list