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

Indexes degrade distinct performance rather than improve them

    • ALL

      On a test set of 5 million records with one of the fields having a value ranging from 0-1000 we're getting some odd performance :

      > d1 = new Date(); db.test.distinct("a"); print(new Date()-d1)
      4086
      > d1 = new Date(); db.test.distinct("a"); print(new Date()-d1)
      4078
      > db.test.ensureIndex(

      {a:1}

      )
      > d1 = new Date(); db.test.distinct("a"); print(new Date()-d1)
      9181
      > d1 = new Date(); db.test.distinct("a"); print(new Date()-d1)
      9183

      Is there any reasonable explanation for this? It would seem that even if for some reason an index causes degraded performance the code shouldn't try and use it (the distinct code on the server implies it should be an optimization)

            Assignee:
            brandon Brandon Diamond
            Reporter:
            remonvv Remon van Vliet
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: