K
K
Khurshed Abdujalil2017-05-17 11:19:50
Yii
Khurshed Abdujalil, 2017-05-17 11:19:50

How to optimize a query in MongoDB?

there are over a million records in mongodb
now i am counting the average price of all query products

$average = round(Product::find()->average('price'));

it is considered more than 2-3 seconds, is it possible to optimize it somehow to make it faster? Or do you still have to cache?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
mitaichik, 2017-05-17
@mitaichik

Do an explain, see what's going on there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question