title: MongoDB FindAndModify extremely slow
body: <p>i'm using mongodb and have some trouble with the speed. My collections got bigger and now contains about 7.000.000 items. As a result, the findAndModify query takes about 3 seconds. I have a index on the queried field (in my case "links", which is an array). Does anybody see a big failure or inefficient code (see below).</p>
  
  <pre><code>public Cluster findAndLockWithUpsert(String url, String lockid) {
     Query query = Query.query(Criteria.where("links").in(Arrays.asList(url)));
     Update update = new Update().push("lock", lockid).push("links", url);
     FindAndModifyOptions options = new FindAndModifyOptions();
     options.remove(false);
     options.returnNew(true);
     options.upsert(true);
     Cluster result = mongo.findAndModify(query, update, options, Cluster.class, COLLECTION);
  
     return result;
  }
  </code></pre>
  
  <p>thank you in advance!</p>