I've create and index for a query and its running is less then 1 second to retrieve millions of rows, but as soon as I add greater than ISODATE, it doesnt use indexes anymore.
the query is this one:
db.getCollection("Coll").find({"Field1.date" : {
$gte: ISODate("2019-11-27T00:00:00.000Z"),
$lte: ISODate("2019-11-28T00:00:00.000Z")
}},{
_id: 1,
"Field2": 1,
"Field3":1,
Field4: 1
})
and i created an index like this:
// db.Coll.createIndex(
// {
// _id: 1,
// "Field2": 1,
// Field4: 1,
// "Field1.date":1
// },
// {background:true , name: "idx_name_date"})
//
but it seems this "field1.date" doesnt work with ISODate.
Asked by Racer SQL
(7546 rep)
Aug 7, 2020, 01:00 PM
Last activity: Jul 31, 2025, 02:01 AM
Last activity: Jul 31, 2025, 02:01 AM