[Dbix-class] prefetch too slow

rahed raherh at gmail.com
Mon Oct 29 13:53:17 GMT 2007


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.

Is there a better and more efficient way?
Thanks much.
      
-- 
Radek




More information about the DBIx-Class mailing list