Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-486

Two indexes same field, one ascending, one descending, cause no index to be used

    • Type: Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 1.1.4
    • Component/s: Index Maintenance
    • None
    • Environment:
      unix

      I had a collection that had two indexes, one ascending, and one descending

      mongo> db.url.getIndexes()
      {
      "_id" : ObjectId("4b1651417fc9cc6b089203f6"),
      "ns" : "scan_stats.url",
      "key" :

      { "hours.velocity" : 1 }

      ,
      "name" : "hours_velocity_1",
      "unique" : false
      },
      {
      "ns" : "scan_stats.url",
      "key" :

      { "hours.velocity" : -1 }

      ,
      "name" : "hours.velocity_-1"
      }

      This query was taking 6 seconds:

      Tue Dec 15 01:37:14 query scan_stats.url ntoreturn:1 reslen:224 nscanned:9236896 { hours.velocity:

      { $gt: 0.0 }

      } nreturned:1 6934

      I removed the unnecessary index (the ascending one), and then the query became instantaneous.

            Assignee:
            eliot Eliot Horowitz (Inactive)
            Reporter:
            douggreen Doug Green
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: