-
Type:
Improvement
-
Resolution: Duplicate
-
Priority:
Major - P3
-
None
-
Affects Version/s: 4.4.3
-
Component/s: None
-
None
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Recently, I started to investigate the performance of MongoDB with AIS Data. I used a collection with 19m documents with proper field types as described in the definition. I also created a new geoloc field with type: (Point) from coordinates (lon,lat) in this same collection.
The query under investigation is:
db.nari_dynamic.explain("executionStats").aggregate(
[
{
$match: {
geoloc: {
$geoWithin: {
$geometry: {
type: "Polygon",
coordinates: [
[
[-5.0, 45.0],
[+0.0, 45.0],
[+0.0, 50.0],
[-5.0, 50.0],
[-5.0, 45.0],
],
],
},
},
},
},
},
{
$group: {
_id: "$sourcemmsi",
PointCount: { $sum: 1 },
MinDatePoint: { $min: { date: "$t3" } },
MaxDatePoint: { $max: { date: "$t3" } },
},
},
{ $sort: { _id: 1 } },
{ $limit: 100 },
{ $project: { _id: 1, PointCount: 1, MinDatePoint: 1, MaxDatePoint: 1 } },
],
{ explain: true }
);
During investigation and testing I found the following:
{{}}
- Without any index: 94s
- With geoloc-2dsphere index: 280s
Of course, I understand that is more complex as the query has a grouping function, but the idea is that usually, we will get something quicker and not slower with the index unless the index causes a different sorting inside the engine like near does.
{{}}
- duplicates
-
SERVER-13065 Consider a collection scan even if indexed plans are available
-
- Backlog
-