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

Compound index with datetime and geospatial fields doesn't work

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Works as Designed
    • Affects Version/s: 3.4.9
    • Fix Version/s: None
    • Component/s: Indexing
    • Labels:
      None
    • Operating System:
      ALL

      Description

      I've created a compound index:

      db.lightningStrikes.createIndex({ datetime: -1, location: "2dsphere" })
      

      But when I run the query below the MongoDB doesn't consider the index, making a COLLSCAN.

      db.lightningStrikes.find({ datetime: { $gte: new Date('2017-10-15T00:00:00Z') } }).explain(true).executionStats
      

      Ps. When I create a compound index by datetime and another type of field it works (searching by index), as below:

      db.lightningStrikes.createIndex({ datetime: -1, source: 1 })
      

      I've seen in the documentation and I haven't found any reason for it.
      https://docs.mongodb.com/manual/core/2dsphere/#create-a-compound-index-with-2dsphere-index-key

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mark.agarunov Mark Agarunov
              Reporter:
              michaelfdias Michael Felix Dias
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: