title: Mongodb server side vs client side processing
body: <p>I have a shell script that creates a cursor on a collection then updates each docunment with data from another collection.<br>
  When I run it on a local db it finishes in about 15 sec, but on a hosted database, it runs for over 45 min.  </p>
  
  <pre><code>db.col1.find().forEach(function(doc) {
      db.col2.findAndModify(
          {
              query: {attr1: doc.attr1},
              update: { $push: {attr2: doc.attr2},
              upsert: true
          });
      });  
  </code></pre>
  
  <p>So there is obviously network overhead between the client and server in order to process this script.  Is there a way to keep the processing all server side?  I have looked at server side javascript, but from what I read <a href="https://stackoverflow.com/questions/12270487/mongodb-what-is-preferable-process-on-server-or-on-client">here</a>, it is not a recommended practice.  </p>