Hi there, I have this time series collection:
{
"t": {
"$date": "2022-04-20T18:20:00.000Z"
},
"c": "5b18b3a6102d58",
"_id": {
"$oid": "635e639985470d444ea26fbb"
},
"v": 13037430
}
I have created the following indexes: t_1_c_1, t_-1_c_1, c_1_t_1, c_1_t_-1
Now, when I run this query:
filter: {"c":"afadf7cfb8cefa7","t":{"$gte":"2024-08-01T00:00:00Z"}}, sorting: {t: 1}
it is resolved within 1 second, but when I do this:
filter: {"c":"afadf7cfb8cefa7","t":{"$lte":"2024-09-01T00:00:00Z"}}, sorting: {t: -1}
it takes minutes!!!
When I run explain in MongoDB Compass, it shows that the ixscan was quick (app 4s) but then fetch takes easily 2 minutes but had seen 5 minutes easily. The best I got to was about 14 seconds!
I tried to use hints but without a real success. It shows that it uses correct index but the data are still being retrieved very slowly.
I have never seen such a behaviour from a DB before.
Any help? Thanks!