MongoDB Aggregation V / S simple query performance?

I am asking this question again because I thought that this question should be in a separate topic from this in-mongodb-know-index-of-array-element-matched-with-in-operator .

I use mongoDB, and in fact I wrote all my queries using simple queries that find, update, etc. (without aggregation). Now I read on many SO posts, see This, for example, mongodb-aggregation-match-vs-find-speed . Now I wondered why the computation time on the server increased, because as if I had calculated more, then my load on the server would become more, so I tried to use aggregates, and I thought that I was going in the right direction now. But later my previous question, andreas-limoli, told me not to use clusters, since it is slow, and to use simple queries and calculations on the server. Now, literally, I'm in delimma about what I should use, I have been working with mongoDB since a year, but I have no knowledge about its performance when increasing the size of the data, so I don’t completely know which one I should choose.

Also, one more thing that I have not found anywhere if aggregation is slower than with $ lookup or not, because $ lookup is the most important thing that I thought about using aggregation, because otherwise I I have to execute a lot of queries one at a time and then calculate on a server, which seems to me very poor before aggregation.

I also read about the 100 MB limit on mongodb aggregation when transferring data from one pipeline to another, as people handle this case efficiently, as well as if they include disk usage, but because disk usage slows everything down than how people handle this case.

I also collected 30,000 samples from the collection and tried to start the aggregation using $ match and find query, and I found that the aggregation was a little faster than finding a query for which the aggregation took 180 ms to execute, where the search performed 220 ms to execute .

Please help me guys, please, that would be very helpful for me.

+5
source share

Source: https://habr.com/ru/post/1261192/


All Articles