David, you\nwrote\nabout Class::DBI performance.
\nEven 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\nAs 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.
\nMatt S Trout <dbix-class@trout.me.uk> says:
\nHowever, 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:
\nmy $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\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\n