[SERVER-14928] $geoIntersect Poor Performance on 2.6.4 Created: 16/Aug/14  Updated: 15/Nov/21  Resolved: 23/Jan/15

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

Type: Bug Priority: Major - P3
Reporter: Ygor Lemos Assignee: Unassigned
Resolution: Incomplete Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Steps To Reproduce:

Just run the sample query.
results are taking more than 1 sec to complete.
Also happened on 2.6.3

Participants:

 Description   

geoIntersect queries are getting very long to complete (~1300ms) against a collection with 5530 polygons / multi polygons (154.41mb)

The query generally returns 2 or 3 documents.

Sample Query:

db.locations.find({"l": {"$geoIntersects": {"$geometry": {"type": "Point", "coordinates": [-47.81302261352539, -21.18204307556152]}}}}, {"m":1,"s":1,"n":1, "c":1})

Query Explain Output:

{
	"cursor" : "BtreeCursor l_2dsphere",
	"isMultiKey" : true,
	"n" : 2,
	"nscannedObjects" : 2,
	"nscanned" : 5,
	"nscannedObjectsAllPlans" : 2,
	"nscannedAllPlans" : 5,
	"scanAndOrder" : false,
	"indexOnly" : false,
	"nYields" : 1,
	"nChunkSkips" : 0,
	"millis" : 1368,
	"indexBounds" : {
		"l" : [
			[
				"4f2211303",
				"4f2211303"
			],
			[
				"4f22113031",
				"4f22113031"
			],
			[
				"4f221130313",
				"4f221130313"
			],
			[
				"4f2211303133",
				"4f2211303133"
			],
			[
				"4f22113031331",
				"4f22113031332"
			]
		]
	},
	"server" : "c0:27017",
	"filterSet" : false
}

Collection Stats:

{
  ns: "pinion.locations",
  count: 5530,
  size: 80728672,
  avgObjSize: 14598,
  storageSize: 161910784,
  numExtents: 4,
  nindexes: 4,
  lastExtentSize: 90599424,
  paddingFactor: 1,
  systemFlags: 1,
  userFlags: 1,
  totalIndexSize: 11250176,
  indexSizes: {
    _id_: 188048,
    l_2dsphere: 10358992,
    t_1: 335216,
    n_1: 367920
  },
  ok: 1
}

Collection Indexes:

[
	{
		"v" : 1,
		"key" : {
			"_id" : 1
		},
		"name" : "_id_",
		"ns" : "pinion.locations"
	},
	{
		"v" : 1,
		"key" : {
			"l" : "2dsphere"
		},
		"name" : "l_2dsphere",
		"ns" : "pinion.locations",
		"background" : true,
		"safe" : true,
		"2dsphereIndexVersion" : 2
	},
	{
		"v" : 1,
		"key" : {
			"t" : 1
		},
		"name" : "t_1",
		"ns" : "pinion.locations",
		"background" : true,
		"safe" : true
	},
	{
		"v" : 1,
		"key" : {
			"n" : 1
		},
		"name" : "n_1",
		"ns" : "pinion.locations",
		"background" : true,
		"safe" : true
	}
]

The documents are large polygon areas like states, districts and municipalities.
Some are regular Polygons, other are MultiPolygons.

The database is running on a Replica Set managed by Compose.io (ex MongoHQ) with a lot of idle hardware.

I have MMS monitoring enabled should more stats are needed.

Locks and Queues are very very low, all other queries returns very fast, including geoNear queries on other collections.



 Comments   
Comment by Daniel Pasette (Inactive) [ 18/Aug/14 ]

the collection is small; would it be possible to mongodump the collection, compress and attach to this ticket?

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