Perl ORM

niceperl on 2008-05-11T06:44:56

I have used Perl DBI and sometimes SQL::Abstract for data-layer. I'd like start to use DBIx::Class or Rose::DB (not decided yet), but I'm not sure about the tunning facilities of this ORM's.
Sometimes, we have complex (very complex) querys writed with no standar SQL (i.e. Oracle rules for using concrete indexes, or PL/SQL calls, etc).

DBI works well for us, perhaps ORM fails in this concrete scenario.


DBIx::Class works for me

grink on 2008-05-11T08:15:16

I haven't had much experience with Rose::DB, but I've been really happy with DBIx::Class.

It's been able to do 90% of the stuff I need out of the box, and for the other 10% you can just grab the dbh handle directly: $schema->storage->dbh

Prefetching is an awesome feature.

See the following on how to do arbitrary (SELECT) SQL through DBIx::Class:

http://search.cpan.org/user/ash/DBIx-Class-0.08010/lib/DBIx/Class/Manual/Cookbook.po d#Arbitrary_SQL_through_a_custom_ResultSource

Good note!

niceperl on 2008-05-11T18:30:11

grink, the link submitted is great, I didn't know this.
What about the performance? I read (High Performance Perl ORM) Rose::DB is fastest than DBIC and CDBI.

Re:Good note!

grink on 2008-05-11T21:43:06

I haven't encountered any performance problems with DBIx::Class

If I did have a time-critical piece of code and DBIx::Class wasn't up to snuff I'd:

1. Use cursoring (via ->next)
2. Fallback to using $schema->storage->dbh
3. Use HashRefInflator: http://search.cpan.org/user/ash/DBIx-Class-0.08010/lib/DBIx/Class/Manual/Cookbook.po d#Skip_object_creation_for_faster_results

It depends on what you're trying to do

Re:Good note!

jjn1056 on 2008-05-13T01:52:03

You can also cache your query results with: http://search.cpan.org/user/mstrout/DBIx-Class-Cursor-Cached-1.0.1/

these works very well if your have a lot of queries that don't often change. You can heavily cache those results and turn it off for your more dynamic queries.

Additionally, there is support for replicated databases and database partitioning. As on the dbix-class IRC channel.

For me, absolute query speed in an abstract sense is not as important as the ability to scale well. That said, I have nothing against other Perl ORMS, just using DBIx-Class very successful on a large social networking site.

Let me know if I can help you with dbic (this is what we call DBIx-Class when we are tired, lazy, etc.)