I’m using mongodb ext for yii2 however, i noticed it still uses yii->db->xxxx for a lot of items.
I kept running out of memory in my php. All it would say is it exhusted all of the memory with no error code. So I upped it and upped it and upped it until i could get it to work.
So the page is using 526m which is absolutely ridiculous.
I’m using
listview
mongo/ActiveRecord
mongo/Query
4 Fields (id, name, desc, date) all of them have the same data as well minus the id (id, "TEST", "TEST", "") so a very very minimal amount of data to be returned.
440,000 collections (i.e. rows for you SQL people)
public function search($params) {
$query = new Query;
$query = Objects::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
'pagination' => array('pageSize' => isset($session['pageSize']) ? $session['pageSize'] : Yii::$app->params['defaultPageSize'])
]);
if (!($this->load($params) && $this->validate())) {
return $dataProvider;
}
$query->andFilterWhere([
'_id' => $this->_id
]);
$query->orWhere(['like', 'name', $this->name]);
return $dataProvider;
}
I tried limiting what the query returns but i can’t seem to get it to work. i.e. limit(24)
So my question is what does limit() do?
Is it suposeto limit the number of returned results?
i.e. xxx->limit(24); should return only 24 results
If so, i can’t seem to get it to work for Mongodb queries. The limit in any of the queries i.e. activeQuery, Query, activeRecord->find() don’t work. It always returns all (440k) of my records.
Anyone know a way to reduce the memory usages / what i’m doing wrong/ ideas to try please share!!!