[Nitro] OG vs Active Record

Jonathan Buch john at oxyliquit.de
Wed Aug 22 10:18:28 EDT 2007


Hi,

>> I hope whoever implements an acts_as_tree for Og has the hindsight and
>> foresight to implement a cached tree structure option -- perhaps with
>> update timestamps to allow simple, fast, partial cache refresh.

Og standard has a hierarchical (Nested Sets), which generates a tree out
of a model comparable to acts_as_tree (I think).

Why I dumped it:  complexity.

There is no way you can update such a structure (same with Nested Intervals)
by hand, moving children to a new parent is hell and inserting is 6 queries
(in the case of Og) instead of 1 and still can fail when using multithreading.

> I am attaching an Og Mixin I use for hierarchical queries in my projects. I
> think this greatly demonstrates the power of Og when encapsulating complex
> patterns.  Consider this example when reviewing Og vs AvtiveRecord.
>
> I think this generates fairly optimized queries and caching is not needed.

Same as Nested Sets, Nested Intervals are hell with inserting/updating.  They
additionally have a limitation on the depth/size of the tree.  While this is
ok for small sets of data, bigger ones it rules out.
Again, the pure complexity makes it very much impractical to do stuff
'by hand'.  Updating here is quicker than with NestedSets it seems, although
right now the code from G looks like it'd also use ~4 queries (only a quick
glance, haven't looked at actual queries).

Nontheless, both, and NestedIntervals in particular, are incredibly
interesting and very nice for many usecases.

On the topic of caching, caching is a hard problem....   I'm now more for
caching the end result and not a single query (which is Georges' stance as
well I think).

Jo

-- 
Feel the love
http://pinkjuice.com/pics/ruby.png


More information about the Nitro-general mailing list