-
Type: Task
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
Labels:None
-
Fully Compatible
-
Query Execution 2021-05-03
In SERVER-52907, we extended the SBE ixscan stage to have a slot for the snapshot id. The snapshot id slot is currently only reset during IndexScanStage::prepare().
When performing a fetch, the seek stage will consult the value of this slot in order to determine whether the index key may have survived a yield. If the snapshot id associated with the index key is not equal to the current snapshot id, then some expensive checks are performed in order to make sure that the document being fetched still matches the query predicate.
The problem is that the value of the ixscan's snapshot id slot is not updated during a yield. Imagine a long-running index scan plan which yields several times. This means that after the first yield, all index keys will be associated with a stale snapshot id, and the expensive validity checks involving index key generation will be performed unnecessarily. Index key generation is known to be expensive, so this is likely to be a performance problem.
In order to fix the performance problem, we should update the snapshot id held in the ixscan stage's snapshot id slot during yield recovery, i.e. during IndexScanStage::doRestoreState().