$geoWithin and $box query taking too long to return results

Hi Team,

I have got around 100 million records with point geometry (epgs:4326) and a simple query to find the points within the given bbox is taking almost 16 secs irrespective of the size of the bbox and inspite of having 2dsphere index applied on point field . Essentially goal is to get the points with viewing bbox and filtering on type field too.

Using Mongodb Enterprise database (7.0.5) on Ubuntu cloudVM

Not sure what am I missing and would be much appreciated if there is a fix or to find alternative solution to it.

{pt: {$geoWithin: { $box: [ [ -74.00084185059065 , 40.72952065151253], [ -73.97420402981133 ,40.75592428599764] ]}}}

Explain details:
{
“stage”: “COLLSCAN”,
“filter”: {
“pt”: {
“$geoWithin”: {
“$box”: [
[
-74.00084185059065,
40.72952065151253
],
[
-73.97420402981133,
40.75592428599764
]
]
}
}
},
“nReturned”: 89229,
“executionTimeMillisEstimate”: 17826,
“works”: 108596805,
“advanced”: 89229,
“needTime”: 108507575,
“needYield”: 0,
“saveState”: 108596,
“restoreState”: 108596,
“isEOF”: 1,
“direction”: “forward”,
“docsExamined”: 108596804
}

-Prem

Hi @Prem_Thogiti

Update the query to use a geojson object such as a Polygon.

https://www.mongodb.com/docs/manual/reference/operator/query/box/#behavior

Only the 2d geospatial index supports $box.

So this only support legacy coordinate pairs.