It will be much faster in your test if you write something like this:
my $resultset = $schema->resultset(...)->search(...);
$resultset->result_class('DBIx::Class::ResultClass::HashRefInflator');
sub dbic_HashRefInflator {
my @req = $resultset->all;
}
Because the creation of new resultset (on every ->resultset, ->search
->[relation]) is very expensive.
if you use perl 5.10 the best practise is
sub mysub {
state $rs = $schema->resultset(...)->search([constant params]);
my @result = $rs->all;
or
my @result = $rs->search([runtime params]);
}
2009/1/12 Jochen Luig <[email protected]>
> Am Montag, den 12.01.2009, 14:37 +0200 schrieb Bogdan Lucaciu:
>
> > try this instead:
> >
> > sub dbic_HashRefInflator {
> > my $resultset = $schema->resultset('MyAppDB::Request')->search(;
> > {message_id => \"IN (173, 174, 171, 1, 168, 144, 177, 111, 178,
> > 172, 95, 196, 179)"},
> > {
> > columns=>[qw/ id message_id created status amount /]
> > },
> > );
> > $resultset->result_class('DBIx::Class::ResultClass::HashRefInflator');
> > @req = $resultset->all;
> > }
> >
>
> Thanks a lot, that worked.
>
> For whom it may concern, this is the new benchmark:
>
> (warning: too few iterations for a reliable count)
> Rate dbic hashrefinflator plain_dbi
> dbic 0.154/s -- -96% -100%
> hashrefinflator 3.87/s 2408% -- -99%
> plain_dbi 625/s 405225% 16063% --
>
>
> Jochen
>
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive:
> http://www.grokbase.com/group/[email protected]
>
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]