Mongo DB query between dates is taking too long for last 10 days but not for more than 10

40 Views Asked by At

Below query is giving results with in time frame ::

db.getCollection('XXX').find({'id':'YY', 'date' : { 
        $lt: new Date(), 
        $gte: new Date(new Date().setDate(new Date().getDate()-15))
      } })

but when I run ::

db.getCollection('XXX').find({'id':'YY', 'date' : { 
        $lt: new Date(), 
        $gte: new Date(new Date().setDate(new Date().getDate()-10))
      } })

it is taking too much time. I am using robo 3t to fetch results.

0

There are 0 best solutions below