-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Closed
Labels
Description
Model::find()->one();
generate
SELECT * FROM ModelTable;
and mysql return all records from table. Then yii use fetch to return first row of result. But all result already in memory.
In our project we have table with 77 million records. Such query use 20.83 gb of memory. But if we add limit(1) it use only 3.5mb.
I think one() should set limit(1) something like this:
public function one($db = null)
{
return $this->limit(1)->createCommand($db)->queryOne();
}
I can submit PR.