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

Slow $geoIntersects on MultiPoint

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Incomplete
    • Icon: Critical - P2 Critical - P2
    • None
    • 2.6.3
    • Geo, Querying
    • None

    Description

      I am experiencing very slow performance on a MultiPoint field with 2dsphere index.

      My document structure is:

      {
          _id: 'anything',
          locs: {  //2dsphere indexed
             "type" : "MultiPoint",
              "coordinates" : [ 
                  [ x1, y1 ], 
                  [ x2, y2],
                  ...
              ]
         }
      }

      I have 10m records of the above documents and I am using $geoIntersects like below to find matched docs out:

      db.collection.find({
          "locs" : {
                  "$geoIntersects" : {
                          "$geometry" : {
                              "type" : "Polygon",
                              "coordinates" : [ 
                                  [ 
                                      [ 
                                          151.1953097969488, 
                                          -33.87301779694879
                                      ], 
                                      [ 
                                          151.2171042030512, 
                                          -33.87301779694879
                                      ], 
                                      [ 
                                          151.2171042030512, 
                                          -33.89481220305122
                                      ], 
                                      [ 
                                          151.1953097969488, 
                                          -33.89481220305122
                                      ], 
                                      [ 
                                          151.1953097969488, 
                                          -33.87301779694879
                                      ]
                                  ]
                              ]
                          }
                      }
                  }
      });

      It takes 20s to return 700 records which is extremely slow. So I did test on making the MultiPoint filed to a Point (just take the first one in the MultiPoint aray and also 2dsphere indexed) field.

      So my doc structure is

      {
          _id: 'anything',
          locs: {  //2dsphere indexed
             "type" : "Point",
              "coordinates" :  [ x1, y1 ] 
         }
      }

      and then run the same query again. Surprisingly, it returns really fast (less than100ms).

      Would anyone give me a hint or walk around before MongoDb team fixes it?

      Attachments

        Activity

          People

            thomas.rueckstiess@mongodb.com Thomas Rueckstiess
            ldsenow ldsenow
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: