yii2-mongodb icon indicating copy to clipboard operation
yii2-mongodb copied to clipboard

Yii2 mongodb ActiveRecord select query very slow event if there have many rows.

Open nishanthrk opened this issue 5 years ago • 2 comments

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

nishanthrk avatar Oct 12 '18 10:10 nishanthrk

is it faster if you try the same query without Yii?

cebe avatar Oct 12 '18 12:10 cebe

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})

nishanthrk avatar Oct 17 '18 12:10 nishanthrk