Would the change of behaviour coincide with an upgrade from 6.0 to 7.0 ?

When I test it with 6.0 v 7.0 there is a change in plan from an IXSCAN with the lower bound matching result of the $dateSubtract 7.0 is the COLLSCAN.

Possibly a bug, try opening an issue on jira.mongodb.com

As a work around adding last_processed_time:{$gt: MinKey()} to the match will use the index but it will still scan more keys than what I observed in 6.0

A preceeding {$sort:{last_processed_time:1}} triggers that same plan as the $gt .

1 Like