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

$geoIntersects is very slow compared to 2.4

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.6.0-rc0
    • Component/s: Geo
    • None
    • ALL

      Here are the indexes:

      db.usa.getIndexes();
      [
              {
                      "v" : 1,
                      "key" : {
                              "_id" : 1
                      },
                      "ns" : "zcta.usa",
                      "name" : "_id_"
              },
              {
                      "v" : 1,
                      "key" : {
                              "coords" : "2dsphere"
                      },
                      "ns" : "zcta.usa",
                      "name" : "coords_2dsphere"
              }
      ]
      

      Mongo 2.4 explain

      db.usa.find( {"coords":{"$geoIntersects":{"$geometry":{"type":"Point","coordinates":[-73.909472,40.876547]}}}}, {"city":1} ).explain();
      {
              "cursor" : "S2Cursor",
              "isMultiKey" : true,
              "n" : 1,
              "nscannedObjects" : 1,
              "nscanned" : 55,
              "nscannedObjectsAllPlans" : 1,
              "nscannedAllPlans" : 55,
              "scanAndOrder" : false,
              "indexOnly" : false,
              "nYields" : 0,
              "nChunkSkips" : 0,
              "millis" : 34,
              "indexBounds" : {
      
              },
              "nscanned" : 55,
              "matchTested" : NumberLong(9),
              "geoTested" : NumberLong(9),
              "cellsInCover" : NumberLong(1),
              "server" : ""
      }
      

      Mongo 2.6 explain:

      db.usa.find( {"coords":{"$geoIntersects":{"$geometry":{"type":"Point","coordinates":[-73.909472,40.876547]}}}}, {"city":1} ).explain();
      {
              "cursor" : "BtreeCursor coords_2dsphere",
              "isMultiKey" : true,
              "n" : 1,
              "nscannedObjects" : 9,
              "nscanned" : 58,
              "nscannedObjectsAllPlans" : 63,
              "nscannedAllPlans" : 112,
              "scanAndOrder" : false,
              "indexOnly" : false,
              "nYields" : 31,
              "nChunkSkips" : 0,
              "millis" : 4118,
              "indexBounds" : {
                      "coords" : [
                              [
                                      "4f1032011",
                                      "4f1032011"
                              ],
                              [
                                      "4f10320113",
                                      "4f10320113"
                              ],
                              [
                                      "4f103201132",
                                      "4f103201132"
                              ],
                              [
                                      "4f1032011321",
                                      "4f1032011321"
                              ],
                              [
                                      "4f10320113213",
                                      "4f10320113214"
                              ]
                      ]
              },
              "server" : "",
              "filterSet" : false
      }
      

      2 second difference.

            Assignee:
            amalia.hawkins@10gen.com Amalia Hawkins
            Reporter:
            rookie7799 Pavel Baranov
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: