title: Mongodb query optimization - running query in parallel
body: <p>I am trying to run some wild card/regex based query on mongo cluster from java driver.
  Mongo Replica Set config:
  3 member replica
  16 CPU(hyperthreaded), 24G RAM Linux x86_64
  Collection size: 6M rows, 7G data</p>
  
  <p>Client is localhost (mac osx 10.8) with latest mongo-java driver</p>
  
  <p>Query using java driver with readpref = primaryPreffered</p>
  
  <pre><code> { "$and" : [{ "$or" : [ { "country" : "united states"}]} , { "$or" : [ { "registering_organization" : { "$regex" : "^.*itt.*hartford.*$"}} , { "registering_organization" : { "$regex" : "^.*met.*life.*$"}} , { "registering_organization" : { "$regex" : "^.*cardinal.*health.*$"}}]}]}
  </code></pre>
  
  <p>I have regular index on both "country" and "registering_organization". But as per mongo docs a single query can utilize only one index and I can see that from explain() on above query as well.</p>
  
  <p>So my question is what is the best alternative to achieve better performance in above query.
  Should I break the 'and' operations and do in memory intersection. Going further I shall have 'Not' operations in query too.</p>
  
  <p>I think my application may turn into reporting/analytics in future but that's not down the line or i am not looking to design accordingly.</p>