Optimizing Query for a large result set in AEM
I have the below query which is used to get all the images added (in two of the paths) which were created between two dates.
SELECT * FROM [dam:Asset] AS a WHERE ((ISDESCENDANTNODE(a,[/content/dam/wknd/en/site])) OR (ISDESCENDANTNODE(a,[/content/dam/wknd/en/site2]))) AND a.[jcr:created] > CAST('2023-01-29T21:30:00.000Z' AS DATE) AND a.[jcr:created] < CAST('2023-01-30T21:30:00.000Z' AS DATE)
In local the query is working fine and giving results.
But in dev it gives the below error.

The query is already picking an index. I validated that using query manager tool.
I have more than 3 million images residing in one path used in the query and around 100,000 images created between these dates.
How can I optimize this query to give results , even though I have 3 million images in those paths?
