[Catalyst] DBIC and RDBO compared (was: Choosing the right ORM)

Perrin Harkins perrin at elem.com
Thu Dec 1 03:05:14 CET 2005


On Wed, 2005-11-30 at 20:39 -0500, John Siracusa wrote:
> For GROUP BY, there is a bit of a a problem when using any ORM that requires
> each object to have a primary key.  If you just want to use an object as a
> temporary container for row data, it'll be okay, but it's still not a good
> match.

It's useful with HAVING in certain conditions when you can group by the
primary key and use aggregate functions to qualify results based on
joins.  It is pretty esoteric though.

> In these situations, what I tend to do is run the custom SQL using DBI and
> then instantiate one or more RDBO objects manually from each row.

That's probably enough for most situations.

> When you use CDBI to do custom queries, do you make sure that the columns
> returned match the expectations of your CDBI class?

Yes.

> If so, then my
> commented-out get_objects_from_sql() method does the same thing.

Sounds pretty similar to what I do with Class::DBI.

> I only benched MySQL with MyISAM, which doesn't do anything interesting
> during prepare() anyway.

It still seems to help MySQL a little because it avoids some object
setup overhead.

> I'll bench Pg later to see if it makes a difference.

I remember it having a huge impact on Oracle, so maybe Pg will be
similar.

> Also, I only used prepare_cached() in the places where I expect the SQL to
> be identical over time: things like save() and delete().  I don't use it at
> all in the Manager, where each query can be different.

I would still use it there, maybe with a switch to disable it.  Most
applications have a specific range of queries that they repeat, and it's
typically a pretty small set.

- Perrin




More information about the Catalyst mailing list