diff options
author | Ted Tuckman <TedTuckman@users.noreply.github.com> | 2023-01-30 13:31:26 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-01-30 14:07:45 +0000 |
commit | eaf46a53c22a464a22a004c0490bca54ac781af5 (patch) | |
tree | 414cbefa4dfff147807c3826184b691c4c326587 /src/mongo | |
parent | 4173d3db39702bb69cadcb6e300587be81f0ec4c (diff) | |
download | mongo-eaf46a53c22a464a22a004c0490bca54ac781af5.tar.gz |
SERVER-73365 Skip double rebuild during path lowering
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/db/query/optimizer/rewrites/path_lower.cpp | 12 | ||||
-rw-r--r-- | src/mongo/db/query/optimizer/rewrites/path_lower.h | 8 |
2 files changed, 12 insertions, 8 deletions
diff --git a/src/mongo/db/query/optimizer/rewrites/path_lower.cpp b/src/mongo/db/query/optimizer/rewrites/path_lower.cpp index ba906daa40b..6fcd8f273c3 100644 --- a/src/mongo/db/query/optimizer/rewrites/path_lower.cpp +++ b/src/mongo/db/query/optimizer/rewrites/path_lower.cpp @@ -31,7 +31,7 @@ namespace mongo::optimizer { -bool EvalPathLowering::optimize(ABT& n) { +bool EvalPathLowering::optimize(ABT& n, bool rebuild) { _changed = false; algebra::transport<true>(n, *this); @@ -39,7 +39,7 @@ bool EvalPathLowering::optimize(ABT& n) { // This is needed for cases in which EvalPathLowering is called from a context other than during // PathLowering. If the ABT is modified in a way that adds variable references and definitions // the environment must be updated. - if (_changed) { + if (_changed && rebuild) { _env.rebuild(n); } @@ -223,7 +223,7 @@ void EvalPathLowering::transport(ABT& n, const EvalPath&, ABT& path, ABT& input) _changed = true; } -bool EvalFilterLowering::optimize(ABT& n) { +bool EvalFilterLowering::optimize(ABT& n, bool rebuild) { _changed = false; algebra::transport<true>(n, *this); @@ -231,7 +231,7 @@ bool EvalFilterLowering::optimize(ABT& n) { // This is needed for cases in which EvalFilterLowering is called from a context other than // during PathLowering. If the ABT is modified in a way that adds variable references or // definitions the environment must be updated. - if (_changed) { + if (_changed && rebuild) { _env.rebuild(n); } @@ -414,11 +414,11 @@ void EvalFilterLowering::transport(ABT& n, const EvalFilter&, ABT& path, ABT& in } void PathLowering::transport(ABT& n, const EvalPath&, ABT&, ABT&) { - _changed = _changed || _project.optimize(n); + _changed = _changed || _project.optimize(n, false /*rebuild*/); } void PathLowering::transport(ABT& n, const EvalFilter&, ABT&, ABT&) { - _changed = _changed || _filter.optimize(n); + _changed = _changed || _filter.optimize(n, false /*rebuild*/); } bool PathLowering::optimize(ABT& n) { diff --git a/src/mongo/db/query/optimizer/rewrites/path_lower.h b/src/mongo/db/query/optimizer/rewrites/path_lower.h index 59df0f50050..6d156f60cbf 100644 --- a/src/mongo/db/query/optimizer/rewrites/path_lower.h +++ b/src/mongo/db/query/optimizer/rewrites/path_lower.h @@ -71,7 +71,9 @@ public: // The tree is passed in as NON-const reference as we will be updating it. // Returns true if the tree changed. - bool optimize(ABT& n); + // If 'rebuild' is set to false will assume the caller will rebuild the VariableEnvironment and + // so will skip the rebuild on the passed in ABT. + bool optimize(ABT& n, bool rebuild = true); private: // We don't own these. @@ -119,7 +121,9 @@ public: // The tree is passed in as NON-const reference as we will be updating it. // Returns true if the tree changed. - bool optimize(ABT& n); + // If 'rebuild' is set to false will assume the caller will rebuild the VariableEnvironment and + // so will skip the rebuild on the passed in ABT. + bool optimize(ABT& n, bool rebuild = true); private: // We don't own these. |