[Nitro] OG vs Active Record
john at oxyliquit.de
Mon Aug 20 20:07:09 EDT 2007
> If you want speed you need to be very careful about how you use
> ORMs with large datasets.
true words. :P
> I recently found an ActiveRecord retrieval that made 8 thousand
> individual database calls totally 4 megabytes of generated SQL.
> All calls were to the same, self-referential table.
>The table only has 6,000 rows...
Sounds like someone is trying to fetch a tree recursively. ;)
> I've been thinking about that experience and realized that, as
> systems get large, it makes a lot of sense to have the models be
> as simple as possible -- doing little more than enforcing simple
> constraints -- and have most business and application logic at
> the controller level.
> If that's not possible, then there needs to be a ModelLogic
> layer... MVC becomes MMVC... which despite initial appearances
> does not parse as a Roman Numeral.
This is how I like to do that stuff, it comes more natural to me
than to put everything except cooking coffee into the models.
I like my models clean, with a modest amount of convenience
I for example cringe when I have to move controller stuff down
into the model for convenience' sake and HTML inside the models
make me want to cry for my mommie.
Acually (from long discussions) I'd crank that up to MMMVC, the
new M is for ModelPresentationLogic. Templating is such a hard
Btw, on the matter of 8 thousand queries, let me once more present
my (almost) infamous age old tip on oxyliquit:
End is, don't redo something the DB does better anyway.
PS: ltree (a indexed tree implentation for psql) and Og work
together beautifully (with a few enhancements).
Feel the love
More information about the Nitro-general