[Dbix-class] Problem using DBIx::Class::ResultClass::HashRefInflator

Oleg Pronin syber.rus at gmail.com
Mon Jan 12 23:08:20 GMT 2009


It will be much faster in your test if you write something like this:

my $resultset =3D $schema->resultset(...)->search(...);
$resultset->result_class('DBIx::Class::ResultClass::HashRefInflator');

sub dbic_HashRefInflator {
    my @req =3D $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 =3D $schema->resultset(...)->search([constant params]);
    my @result =3D $rs->all;
    or
    my @result =3D $rs->search([runtime params]);
}


2009/1/12 Jochen Luig <jochen.luig at skytel.de>

> Am Montag, den 12.01.2009, 14:37 +0200 schrieb Bogdan Lucaciu:
>
> > try this instead:
> >
> > sub dbic_HashRefInflator {
> >     my $resultset =3D $schema->resultset('MyAppDB::Request')->search(;
> >         {message_id =3D> \"IN (173, 174, 171, 1, 168, 144, 177, 111, 17=
8,
> > 172, 95, 196, 179)"},
> >         {
> >          columns=3D>[qw/ id message_id created status amount /]
> >         },
> >         );
> > $resultset->result_class('DBIx::Class::ResultClass::HashRefInflator');
> > @req =3D $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/dbix-class@lists.scsys.co.uk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20090113/22e=
5b2bb/attachment.htm


More information about the DBIx-Class mailing list