If you run two queries with the same filter, sort, and projection, they map to the same plan cache key. This happens even when they have different top-level let bindings.
The attached script fails on the default configuration (trySbeEngine). Printing the plan cache in between the two queries shows that the constant 5 is baked in to the plan:
[3] limit 1 [2] project [s3 = makeBsonObj(MakeObjSpec(["_id" = Arg(0)], Closed), s1, 5L)] [1] scan s1 s2 none none none none none none [] @"97a0d744-17cb-4332-aee5-2f196db32553" true false
Running with forceClassicEngine, the test passes, so this is specific to the SBE stagebuilders plan cache.
- is related to
-
SERVER-62100 Refresh “let” variables on SBE plan recovery
- Closed