title: MongoDB OR condition indexing
body: <p>I have an OR query which I'm currently using for a semi large update.  Essentially my collection is split into two data sets;</p>
  
  <p>1 main repository and 1 subset of the main repository.  This is just to allow quicker searching on a small subset of data.</p>
  
  <p>I'm finding however my query which I create to pull things into the subset is timing out.. and when looking at the explain it looks like two queries are actually happening.</p>
  
  <pre><code>PRIMARY&gt; var date = new Date(2012,05,01);
  PRIMARY&gt; db.col.find(
    {"$or":[
        {"date":{"$gt":date}},
        {"keywords":{"$in":["Help","Support"]}}
     ]}).explain();
  </code></pre>
  
  <p>This produces: </p>
  
  <pre><code>{
  "clauses" : [
      {
          "cursor" : "BtreeCursor ldate_-1",
          "nscanned" : 1493872,
          "nscannedObjects" : 1493872,
          "n" : 1493872,
          "millis" : 1035194,
          "nYields" : 3396,
          "nChunkSkips" : 0,
          "isMultiKey" : false,
          "indexOnly" : false,
          "indexBounds" : {
              "ldate" : [
                  [
                      ISODate("292278995-01--2147483647T07:12:56.808Z"),
                      ISODate("2012-06-01T07:00:00Z")
                  ]
              ]
          }
      },
      {
          "cursor" : "BtreeCursor keywords_1 multi",
          "nscanned" : 88526,
          "nscannedObjects" : 88526,
          "n" : 2515,
          "millis" : 1071902,
          "nYields" : 56,
          "nChunkSkips" : 0,
          "isMultiKey" : false,
          "indexOnly" : false,
          "indexBounds" : {
              "keywords" : [
                  [
                      "Help",
                      "Help"
                  ],
                  [
                      "Support",
                      "Support"
                  ]
              ]
          }
      }
  ],
   "nscanned" : 1582398,
   "nscannedObjects" : 1582398,
   "n" : 1496387,
   "millis" : 1071902
  }
  </code></pre>
  
  <p>Is there something I can be indexing better to make this faster? Seems just way to slow...</p>
  
  <p>Thanks ahead of time!</p>