简体   繁体   中英

Real time queries in MongoDB for different criteria and processing the result

New to Mongodb. Is Mongodb efficient for real time queries where the values for the criteria changes every time for my query. Also there will be some aggregation of the resultset before sending the response back to the user. As an example my user case needs to produce the data in the following format after processing a collection for different criteria values.

 Service     Total     Improved
 A           1000      500
 B           2000      700
 ..          ..        ..

I see Mongodb has Aggregation which process records and return computed results. Should I be used aggregation instead for efficiency? If aggregation is the way to go, I guess I would do that every time my source data changes. Also, is this what Mongo Hadoop is used for? Am I on the right track in my understanding? Thanks in advance.

Your question is too general, IMHO.

Speed depends on the size of your data and on the kind of your query and if you have put an index on your key etc. Changing values in your queries are not critical, AFAIK.

For example I work on a MongoDB with 3 million docs and can do some queries in a couple of seconds, some in a couple of minutes. A simple map reduce over all 3 M docs takes about 25 min on that box.

I have not tried the aggregation API yet, which seems to be a successor/alternative to map / reduce runs.

I did not know about the MongoDB / Hadoop integration. It seems to keep MongoDB as an easy-to-use storage unit, which feeds data to a Hadoop cluster and gets results from it, using the more advanced map reduce framework from Hadoop (more phases, better use of a cluster of Hadoop nodes)..

I would follow mongodbs guidelines for counting stuff.

See mongodbs documentation page for preaggregated reports.

Hadoop is good for batch processing, which you probably don´t need for these counting use cases?

See this list for other typical hadoop use cases: link .

And heres a resource for typical mongo+hadoop use cases: link .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM