[SERVER-13135] Some queries using 2dsphere indexes in 2.6 rc1 scan a *lot* more documents than 2.4 Created: 11/Mar/14  Updated: 11/Jul/16  Resolved: 13/Mar/14

Status: Closed
Project: Core Server
Component/s: Geo, Performance
Affects Version/s: 2.6.0-rc1
Fix Version/s: 2.6.0-rc2

Type: Bug Priority: Minor - P4
Reporter: Rajesh Khot Assignee: hari.khalsa@10gen.com
Resolution: Done Votes: 0
Labels: geospatial
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File ps.json.gz    
Operating System: ALL
Steps To Reproduce:

Import the ps.json file in 2.4 and in 2.6

Run the query to see the difference in nScanned

db.ps.find({'PROV_TIN_ADR.LATLONGDEGREE':{$near:{$geometry:

{type : "Point" ,coordinates : [-78.898619,35.9940329] }

, $maxDistance :482803}}}).limit(300).explain()

Participants:

 Description   

Some geo-spatial queries in 2.6-rc1 scan a lot more documents than older versions. I have a 1.8 million doc collection. In 2.4, the query scans 440K rows, in 2.6, the query scans 1.4 million rows

===== 2.4 ====
> db.ps.find({'PROV_TIN_ADR.LATLONGDEGREE':{$near:{$geometry:

{type : "Point" ,coordinates : [-78.898619,35.9940329] }

, $maxDistance :482803}}}).limit(300).explain()
{
"cursor" : "S2NearCursor",
"isMultiKey" : true,
"n" : 300,
"nscannedObjects" : 300,
"nscanned" : 441680,
"nscannedObjectsAllPlans" : 300,
"nscannedAllPlans" : 441680,
"scanAndOrder" : false,
"indexOnly" : false,
"nYields" : 0,
"nChunkSkips" : 0,
"millis" : 696,
"indexBounds" : {

},
"nscanned" : 441680,
"matchTested" : NumberLong(32280),
"geoMatchTested" : NumberLong(32280),
"numShells" : NumberLong(8),
"keyGeoSkip" : NumberLong(409400),
"returnSkip" : NumberLong(3),
"btreeDups" : NumberLong(0),
"inAnnulusTested" : NumberLong(32280),
"server" : "apxxx:27017"
}

=============== 2.6.rc1 ======================

db.ps.find({'PROV_TIN_ADR.LATLONGDEGREE':{$near:{$geometry:

{type : "Point" ,coordinates : [-78.898619,35.9940329] }

, $maxDistance :482803}}}).limit(300).explain()
{
"cursor" : "S2NearCursor",
"isMultiKey" : false,
"n" : 300,
"nscannedObjects" : 1405044,
"nscanned" : 1405044,
"nscannedObjectsAllPlans" : 1405044,
"nscannedAllPlans" : 1405044,
"scanAndOrder" : false,
"indexOnly" : false,
"nYields" : 10976,
"nChunkSkips" : 0,
"millis" : 8552,
"indexBounds" : {

},
"server" : "apxxx:27017",
"filterSet" : false
}



 Comments   
Comment by Githook User [ 13/Mar/14 ]

Author:

{u'username': u'hkhalsa', u'name': u'Hari Khalsa', u'email': u'hkhalsa@10gen.com'}

Message: SERVER-13135 use key information to filter docs in s2near
Branch: v2.6
https://github.com/mongodb/mongo/commit/09acefaf1e0e79813ebe9b594a78b148a1ffb6dd

Comment by Githook User [ 13/Mar/14 ]

Author:

{u'username': u'hkhalsa', u'name': u'Hari Khalsa', u'email': u'hkhalsa@10gen.com'}

Message: SERVER-13135 use key information to filter docs in s2near
Branch: master
https://github.com/mongodb/mongo/commit/f111b99bd986fca3902730cf394d4f4260116dbe

Comment by Rajesh Khot [ 11/Mar/14 ]

You will need to create the 2dsphere index before running the query..

db.ps.ensureIndex(

{"PROV_TIN_ADR.LATLONGDEGREE" :"2dsphere"}

)

Generated at Thu Feb 08 03:30:45 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.