[SERVER-849] Geospatial Indexing -- Slow Cases Created: 30/Mar/10  Updated: 19/May/14  Resolved: 08/Jul/10

Status: Closed
Project: Core Server
Component/s: Geo
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Kyle Banker Assignee: Richard Kreuter (Inactive)
Resolution: Won't Fix Votes: 2
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File dump.tar.bz2     PNG File server-849.png    
Participants:

 Description   

Certain coordinates result in slow queries. Not sure why. Dataset attached.

Fast:
db.runCommand (

{ geoNear : "people" , near : [65, -97.11291], num : 1}

);

Slow:
db.runCommand (

{ geoNear : "people" , near : [65, -97.11291], num : 2}

);

Fast:
db.runCommand (

{ geoNear : "people" , near : [32.5, -87.8], num : 2}

);



 Comments   
Comment by Richard Kreuter (Inactive) [ 08/Jul/10 ]

As mentioned, this is mostly tripping a worst-case edge in the geohashing algorithm. For now, we recommend that applications use the maxDistance option to geoNear to avoid searching very large spaces. The syntax looks like this:

db.runCommand (

{ geoNear : "people" , near : [65, -97.11291], num : 2, maxDistance:8 }

);

Comment by Richard Kreuter (Inactive) [ 07/Jul/10 ]

This is just an edge case in the algorithm that has bad performance.
As the center of a geoNear search gets farther from the points in a
geolocation data set, the smallest nonempty search box around the
center grows exponentially bigger, and so that box will probably
contain many points. In this case, the smallest nonempty box centered
at [65, -97.11291] contains 1.859M points (result below), and so
finding the point closest to the center is going to be expensive.

> db.runCommand (

{ geoNear : "people" , near : [65, -97.11291], num : 1}

);
{
"ns" : "test.people",
"near" : "1000110111101100010111111000000110101100000011101001",
"results" : [
{
"dis" : 16.208071224350125,
"obj" : {
"_id" : ObjectId("4babbfe45adeec1d659581dc"),
"UniverseId" : 1,
"PersonId" : 427987228,
"loc" :

{ "lat" : 48.799935, "long" : -97.62229 }

}
}
],
"stats" :

{ "time" : 145203, "btreelocs" : 1859005, "nscanned" : 1859007, "objectsLoaded" : 386, "avgDistance" : 16.208071224350125, "maxDistance" : 16.208071224350125 }

,
"ok" : true
}

Comment by Richard Kreuter (Inactive) [ 07/Jul/10 ]

Visualization of data set. Note: this diagram is a plot of 1.89M location points.

Comment by Kyle Banker [ 30/Mar/10 ]

Sample data.

Generated at Thu Feb 08 02:55:21 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.