--- author: email: rafl@fsfe.org keyid: 742f2a428e635a5e name: Florian Ragwitz categories: - Perl comments: [] date: 2006-06-11T11:36:58Z guid: cfe661e2-1ca1-453f-9b97-2f9e96debc26 modified: 2007-10-17T22:37:48Z raw: "=pod\n\nL, you\nL\nabout L performance.\n\nEven without benchmarking you could have\nL,\nthat Class::DBI is quite slow. Fortunately there are some alternative\nobject-relational mappers available in the perl universe. The best ones I found\nso far are\nL and\nL. I took a closer\nlook at both and would like to share my experience.\n\n\nAs L shows,\nRDBO is faster than DBIC in most of the case. The generated SQL doesn't differ\ntoo much and therefor it must be the perl side of things that makes the\ndifference.\n\nMatt S Trout says:\n\n However, RDBO achieves its perl speed by aggressive inlining of\n stuff etc. - for example the main object retrieval function in\n RDBO's manager class is >3000 lines in a single sub. DBIC values\n extensibility over a few extra sub calls, so methods are much more\n broken out and there are many more ways to hook into the DBIC\n execution process to extend.\n\n\nAlso its idea of resultsets is something I really love. Here's a small example to illustrate that:\n\n lang:Perl\n my $user_rs = $schema->resultset('User')->search({ registered => 1 });\n $user_rs = $user_rs->search(\n\t\t { comment.title => 'Foo' },\n\t\t {\n\t\t \tjoin => { 'article' => 'comment' },\n\t\t\torder_by => 'user.name',\n\t\t },\n );\n\n # no sql executed yet.\n # now you can use your resultset as an iterator or query a list\n # of User objects from it or ..\n\n while (my $user = $user_rs->next) {\n\t ...\n }\n\n # or\n\n my $count = $user_rs->count;\n\n\nUsing these resultset makes it extremely easy to built up queries piece by\npiece and to work together well with, for example, a templating system. You\ndon't need to fetch all row-objects and give them to your template. You can\njust pass the iterator to the template library.\n\n\nThere's a lot more to say about this two object-relational mappers (for example\nRDBO supports prefetching of multiple one-to-many at once, which DBIC doesn't),\nbut maybe you just should take a look yourself. I personally prefer DBIx::Class\nfor its vast extensibility.\n\n=cut\n" signed: 1 summary: " David, you wrote about Class::DBI performance. Even without benchmarking …" tags: [] text: " David, you wrote about Class::DBI performance.\n\n Even without benchmarking you could have found out, that Class::DBI\n is quite slow. Fortunately there are some alternative object-rela-\n tional mappers available in the perl universe. The best ones I found\n so far are Rose::DB::Object and DBIx::Class. I took a closer look at\n both and would like to share my experience.\n\n As this shows, RDBO is faster than DBIC in most of the case. The\n generated SQL doesn't differ too much and therefor it must be the\n perl side of things that makes the difference.\n\n Matt S Trout says:\n\n However, RDBO achieves its perl speed by aggressive inlining of\n stuff etc. - for example the main object retrieval function in\n RDBO's manager class is >3000 lines in a single sub. DBIC values\n extensibility over a few extra sub calls, so methods are much more\n broken out and there are many more ways to hook into the DBIC exe-\n cution process to extend.\n\n Also its idea of resultsets is something I really love. Here's a s-\n mall example to illustrate that:\n\n lang:Perl my $user_rs = $schema->resultset('User')->search({ reg-\n istered => 1 }); $user_rs = $user_rs->search( { comment.title =>\n 'Foo' }, { join => { 'article' => 'comment' }, order_by => 'user.-\n name', }, );\n\n # no sql executed yet. now you can use your resultset as an itera-\n # tor or query a list of User objects from it or ..\n\n while (my $user = $user_rs->next) { ... }\n\n # or\n\n my $count = $user_rs->count;\n\n Using these resultset makes it extremely easy to built up queries\n piece by piece and to work together well with, for example, a tem-\n plating system. You don't need to fetch all row-objects and give\n them to your template. You can just pass the iterator to the tem-\n plate library.\n\n There's a lot more to say about this two object-relational mappers\n (for example RDBO supports prefetching of multiple one-to-many at\n once, which DBIC doesn't), but maybe you just should take a look y-\n ourself. I personally prefer DBIx::Class for its vast extensibility.\n" title: Class::DBI is dead type: pod uri: http://metacpan.perldition.org/articles/Class%3A%3ADBI%20is%20dead.pod xhtml: "
\n

David, you\nwrote\nabout Class::DBI performance.

\n

Even without benchmarking you could have\nfound out,\nthat Class::DBI is quite slow. Fortunately there are some alternative\nobject-relational mappers available in the perl universe. The best ones I found\nso far are\nRose::DB::Object and\nDBIx::Class. I took a closer\nlook at both and would like to share my experience.

\n\n\n\n

As this shows,\nRDBO is faster than DBIC in most of the case. The generated SQL doesn't differ\ntoo much and therefor it must be the perl side of things that makes the\ndifference.

\n

Matt S Trout <dbix-class@trout.me.uk> says:

\n
However, RDBO achieves its perl speed by aggressive inlining of\nstuff etc. - for example the main object retrieval function in\nRDBO's manager class is >3000 lines in a single sub. DBIC values\nextensibility over a few extra sub calls, so methods are much more\nbroken out and there are many more ways to hook into the DBIC\nexecution process to extend.\n\n\n
\n

Also its idea of resultsets is something I really love. Here's a small example to illustrate that:

\n
my $user_rs = $schema->resultset('User')->search({ registered => 1 });\n$user_rs    = $user_rs->search(\n  { comment.title => 'Foo' },\n  {\n  \tjoin     => { 'article' => 'comment' },\n\torder_by => 'user.name',\n  },\n);\n\n# no sql executed yet.\n# now you can use your resultset as an iterator or query a list\n# of User objects from it or ..\n\nwhile (my $user = $user_rs->next) {\n ...\n}\n\n# or\n\nmy $count = $user_rs->count;\n\n\n
\n

Using these resultset makes it extremely easy to built up queries piece by\npiece and to work together well with, for example, a templating system. You\ndon't need to fetch all row-objects and give them to your template. You can\njust pass the iterator to the template library.

\n\n\n\n

There's a lot more to say about this two object-relational mappers (for example\nRDBO supports prefetching of multiple one-to-many at once, which DBIC doesn't),\nbut maybe you just should take a look yourself. I personally prefer DBIx::Class\nfor its vast extensibility.

\n\n\n
"