yii2-mongodb
yii2-mongodb copied to clipboard
Yii2 mongodb ActiveRecord select query very slow event if there have many rows.
What steps will reproduce the problem?
using yii\mongodb\Query; $query->select(['data']) ->from('log') ->where(['userId' => 12234]) ->limit(10);
using ActiveRecord $result = Log::find() ->select(['data']) ->where(['userId' => 12234]) ->orderBy(['addedOn' => SORT_DESC]) ->offset(0)->limit(10) ->asArray() ->all();
What's expected?
I have around 10528546 document in that collection and it is taking more then one minute to execute the query
Additional info
Q | A |
---|---|
Yii version | 2.0.6 |
Yii MongoDB version | 2.1.0 |
MongoDB server version | 3.6 |
PHP version | 7.0 |
Operating system | Ubuntu 16 |
is it faster if you try the same query without Yii?
When i executve the same query in mongo console or robo 3t it took only approximate 10 sec
Query: db.getCollection('log').find({'userId': 23453})