[Dbix-class] prefetch too slow

Matt S Trout dbix-class at trout.me.uk
Mon Oct 29 16:07:12 GMT 2007


On Mon, Oct 29, 2007 at 02:53:17PM +0100, rahed wrote:
> Hi,
> 
> in Catalyst I get a resultset from five tables roughly like this:
> (actualy there are more columns)
> 
> $rs = $c->model('MyAppDB:Tab1')->search(undef,
>       {prefetch=> {rel1=>{rel2=>['rel3','rel4']}},
>        select  => ['me.id','me.col2',
>                    \'strftime(\'%s\',date)',
>                   ],
>        as      => [qw/id col2 col3/],
>        rows    => 1000,
>        page    = $page,
>        },
>        );
> 
> Then I step through the resultset like this:
> 
> while (my $row = $rs->next) {
>   some stuff ...
> }
> 
> The query takes around one minute nevertheless from a command line the same
> one retrieves the data within one second.
> The time is spent within the next method.
> Is something wrong with this approach?
> 
> I've lived with it by limiting the rows option to 50 but now I'd like to
> put all data (more than 10000 rows) into a file.

If it's 10k+ rows it's probably pure object inflation overhead.

Why not use the HashRefInflator cookbook entry to bypass that?

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director                    http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/            http://www.shadowcat.co.uk/servers/



More information about the DBIx-Class mailing list