-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
Query Optimization
-
Fully Compatible
-
QO 2024-03-18
Currently PlanExplainerImpl::getSummaryStats makes repeated calls to stageType() which is a virtual function. Since this is a virtual function, the compiler cannot inline the call and also must repeat the call each time it is called as written in the code. A savings of a few instructions and a few function calls can be done by storing the result of this function call in a local variable.
Current Code
if (STAGE_IXSCAN == stages[i]->stageType()) { ... } else if(STAGE_COUNT_SCAN == stages[i]->stageType()) { ...
Suggested Improvement
auto stageType = stages[i]->stageType(); if (STAGE_IXSCAN == stageType) { ... } else if(STAGE_COUNT_SCAN == stageType) { ...