title: Mongo script runs quickly locally but slow if I run it against a remote instance?
body: <p>I have a mongo script that I am using to perform some data cleanup after a database migration.</p>
  
  <p>When I run this script locally it finishes in about 5 minutes.  When I run the script from my local machine against a remote instance it takes forever (I usually kill it after about two hours).  These databases are essentially identical.  Indexes are all the same, maybe a few records in one place that isn't in the other.</p>
  
  <p>I am executing the script like so:</p>
  
  <p>Locally-</p>
  
  <pre><code>mongo localDatabase script.js
  </code></pre>
  
  <p>Against remote instance-</p>
  
  <pre><code>mongo removeServer/remoteDatabase -u user -p password script.js
  </code></pre>
  
  <p>I had assumed that since I was passing the script to the remote instance it would be executed entirely on the remote machine with no data having to be transported back and forth between the remote machine and my local machine (and hence there would be little difference in performance).  </p>
  
  <p>Is this assumption correct?  Any idea why I am seeing the huge performance difference between local/remote?  Suggestions on how to fix?</p>