MongoDb agregation vs client side data manipulation -


i need load set of data mongodb. let's assume, need have items list based on condition, need know items children count, need include embedded documents have "moderated = true" , count subdocuments "moderated == false" without including them. since have document embedded document, can retrieve set of data db , manipulate on client side "for". , can use

db.item.aggregate 

to create response data need , response have exact needed structure.

the question better approach in terms of reducing load on mongodb:

  1. aggregation mongodb?
  2. create needed data on client side?

this strange question. really, if care reducing load on mongodb, it's better send data need , computation on client. defeats of purpose of using mongodb. real question is, why prioritizing reducing load on mongodb? presumably aggregation not main load on server , don't want impact core operations aggregation? in case, solution add hidden secondary replica set (you running mongodb in replica set already, right? ;d) , hidden secondary's purpose handle data analytics tasks aggregation. data state on hidden secondary may behind data state on primary, depending on replication lag, that's ok analytics.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -