SELECT * FROM FLATTEN(orders)
WHERE
updatedAt >= CAST('2024-01-29T12:56:05.408301+00:00' AS BSON_DATE)
AND updatedAt <= CAST('2024-02-29T12:56:05.408301+00:00' AS BSON_DATE)
LIMIT 100
OFFSET 0
This query takes 21 Seconds to run. there are only 34k documents in the collection
if I now add an UNWIND to the mix - which is our Key reason for using the DATA federation system - the following query now takes 3 Minutes.
SELECT * FROM FLATTEN(UNWIND(orders WITH PATH => items) WITH SEPARATOR=> '__')
WHERE
updatedAt >= CAST('2024-01-29T12:56:05.408301+00:00' AS BSON_DATE)
AND updatedAt <= CAST('2024-02-29T12:56:05.408301+00:00' AS BSON_DATE)
LIMIT 100
OFFSET 0
I have created an index on updatedAt. and I can see it exists in the UI.
Indeed, if I run a find query normally using the following
{updatedAt: {$gte: ISODate('2024-01-29T12:56:05.408301+00:00'), $lte: ISODate('2024-02-29T12:56:05.408301+00:00')}}
The results are almost instantaneous.
This slowness feels wrong.