[CDBI] How well does Class::DBI scale?
siracusa at mindspring.com
Tue Dec 20 01:37:31 GMT 2005
On 12/19/05 8:24 PM, Matt S Trout wrote:
> Of course, if you're refactoring substantially, it's but a short step to
> just port the code to DBIx::Class which has the same features and much less
> perl overhead, and not *so* much longer a step to Rose::DB::Object which
> is rather more different but faster still (speed here in terms of perl
> overhead; the SQL optimisation achievable with each is probably fairly
> similar provided we're comparing Sweet and not plain Class::DBI).
Well, it depends on how your db performs when doing JOINs.
Class::DBI::Sweet, DBIx::Class, and Rose::DB::Object can all auto-join
tables when one row from the main table has one row in a related table.
This is almost always a performance win when compared to doing individual
queries for each related row.
Uniquely, Rose::DB::Object can also auto-join tables related via "one to
many" and "many to many" relationships. This is also a performance win if
you're using a decent database, but it's possible to go overboard by joining
via too many "... to many" relationships and ending up swamped with
I don't know what your table relationships look like, so I can't comment on
which of the modules or approaches will help you. But judging by the number
of queries you're running alone, I can tell you that using an ORM without
any support for automatic JOINs and then using that ORM to fetch your data
is probably a bad idea :)
Whether you just need 1-to-1 JOIN support, or would benefit from 1-to-n and
n-to-n JOIN support as well, I don't know. Maybe you actually need to do
custom SQL no matter what. Again, it's hard to tell without knowing the
Anyway, the Rose::DB::Object module distribution includes a Perl ORM
benchmark suite that compares all the modules listed earlier, including
CDBI. You can see some results here:
or download the becnchmark from CPAN and run it yourself. If you want to
see how much benefit you might get from using the auto-JOIN features of
another ORM, take a look at the "search with ... sub-object" test results in
More information about the ClassDBI