LArge dataset - find breaks....

I have a pretty intense table (44000 items)

When I run :

$arAllmodel = $FromModel::find()->where([’<’,‘id’,10000])->all();

Then I can iterate all models

However when I run:

$arAllmodel = $FromModel::find()->where([’>’,‘id’,1])->all();

to iterate the entire set, the function find never returns

Any ideas?

Check the error log to see if PHP ran out of memory.

Better use batch:


$query = (new Query())->from('model')->orderBy('id');


foreach ($query->batch(100) as $models) {

   // $models is an array of 100 or fewer rows from the user table

   ...

}


// or if you want to iterate the row one by one:


foreach ($query->each() as $model) {

    // $model represents one row of data 

   ...

}

Cool suggestion… never knew about the batch !