Решил сравнить производительность выполнения запросов. Мне не понятно почему на Yii2 код выполнился в два раза медленнее.
Yii1 (0.56 сек):
$command = Yii::app()->db->createCommand();
$command->select('id');
$command->from('task');
$command->limit = 4000;
$result = $command->queryAll();
$data = [];
$start = microtime(true);
foreach($result as $a){
$command = Yii::app()->db->createCommand();
$command->from('task AS T');
$command->where('id = :id', [':id' => $a['id']]);
$command->limit = 1;
$data[] = $command->queryRow();
}
$stop = microtime(true);
$time = $stop - $start;
print_r($time);exit();
Yii2 (0.97 сек):
$query = new Query();
$query->select('id');
$query->from('task');
$query->limit(4000);
$result = $query->all();
$data = [];
$start = microtime(true);
foreach($result as $a){
$query = new Query();
$query->from('task AS T');
$query->where('id = :id', [':id' => $a['id']]);
$query->limit(1);
$data[] = $query->one();
}
$stop = microtime(true);
$time = $stop - $start;
print_r($time);exit();