diff options
author | Matt Boros <matt.boros@mongodb.com> | 2022-08-29 14:46:10 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-08-29 16:08:45 +0000 |
commit | fb2209b3a862e819fed0f21eecd15b8fd4fa9a45 (patch) | |
tree | c285080910e97cd8dd14d3a8f8feae38de3ee798 /src/mongo/db/query/optimizer/utils | |
parent | 0fbba9495da3c621deddbee47cff3fda00b07bec (diff) | |
download | mongo-fb2209b3a862e819fed0f21eecd15b8fd4fa9a45.tar.gz |
SERVER-66783 Explain improvement add triggering rules to memo
Diffstat (limited to 'src/mongo/db/query/optimizer/utils')
-rw-r--r-- | src/mongo/db/query/optimizer/utils/memo_utils.cpp | 12 | ||||
-rw-r--r-- | src/mongo/db/query/optimizer/utils/memo_utils.h | 3 | ||||
-rw-r--r-- | src/mongo/db/query/optimizer/utils/rewriter_utils.cpp | 47 | ||||
-rw-r--r-- | src/mongo/db/query/optimizer/utils/rewriter_utils.h | 40 |
4 files changed, 87 insertions, 15 deletions
diff --git a/src/mongo/db/query/optimizer/utils/memo_utils.cpp b/src/mongo/db/query/optimizer/utils/memo_utils.cpp index 9dfa3e595a2..e4faab813f7 100644 --- a/src/mongo/db/query/optimizer/utils/memo_utils.cpp +++ b/src/mongo/db/query/optimizer/utils/memo_utils.cpp @@ -34,18 +34,6 @@ namespace mongo::optimizer { -ABT wrapConstFilter(ABT node) { - return make<FilterNode>(Constant::boolean(true), std::move(node)); -} - -ABT unwrapConstFilter(ABT node) { - if (auto nodePtr = node.cast<FilterNode>(); - nodePtr != nullptr && nodePtr->getFilter() == Constant::boolean(true)) { - return nodePtr->getChild(); - } - return node; -} - class MemoLatestPlanExtractor { public: explicit MemoLatestPlanExtractor(const cascades::Memo& memo) : _memo(memo) {} diff --git a/src/mongo/db/query/optimizer/utils/memo_utils.h b/src/mongo/db/query/optimizer/utils/memo_utils.h index af28a2c3ef8..1363633b9c5 100644 --- a/src/mongo/db/query/optimizer/utils/memo_utils.h +++ b/src/mongo/db/query/optimizer/utils/memo_utils.h @@ -37,9 +37,6 @@ namespace mongo::optimizer { -ABT wrapConstFilter(ABT node); -ABT unwrapConstFilter(ABT node); - template <class ToAddType, class ToRemoveType> static void addRemoveProjectionsToProperties(properties::PhysProps& properties, const ToAddType& toAdd, diff --git a/src/mongo/db/query/optimizer/utils/rewriter_utils.cpp b/src/mongo/db/query/optimizer/utils/rewriter_utils.cpp new file mode 100644 index 00000000000..88c1427c8df --- /dev/null +++ b/src/mongo/db/query/optimizer/utils/rewriter_utils.cpp @@ -0,0 +1,47 @@ +/** + * Copyright (C) 2022-present MongoDB, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the Server Side Public License, version 1, + * as published by MongoDB, Inc. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * Server Side Public License for more details. + * + * You should have received a copy of the Server Side Public License + * along with this program. If not, see + * <http://www.mongodb.com/licensing/server-side-public-license>. + * + * As a special exception, the copyright holders give permission to link the + * code of portions of this program with the OpenSSL library under certain + * conditions as described in each individual source file and distribute + * linked combinations including the program with the OpenSSL library. You + * must comply with the Server Side Public License in all respects for + * all of the code used other than as permitted herein. If you modify file(s) + * with this exception, you may extend this exception to your version of the + * file(s), but you are not obligated to do so. If you do not wish to do so, + * delete this exception statement from your version. If you delete this + * exception statement from all source files in the program, then also delete + * it in the license file. + */ + +#include "mongo/db/query/optimizer/utils/rewriter_utils.h" + + +namespace mongo::optimizer { + +ABT wrapConstFilter(ABT node) { + return make<FilterNode>(Constant::boolean(true), std::move(node)); +} + +ABT unwrapConstFilter(ABT node) { + if (auto nodePtr = node.cast<FilterNode>(); + nodePtr != nullptr && nodePtr->getFilter() == Constant::boolean(true)) { + return nodePtr->getChild(); + } + return node; +} + +} // namespace mongo::optimizer diff --git a/src/mongo/db/query/optimizer/utils/rewriter_utils.h b/src/mongo/db/query/optimizer/utils/rewriter_utils.h new file mode 100644 index 00000000000..e81190a5ce6 --- /dev/null +++ b/src/mongo/db/query/optimizer/utils/rewriter_utils.h @@ -0,0 +1,40 @@ +/** + * Copyright (C) 2022-present MongoDB, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the Server Side Public License, version 1, + * as published by MongoDB, Inc. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * Server Side Public License for more details. + * + * You should have received a copy of the Server Side Public License + * along with this program. If not, see + * <http://www.mongodb.com/licensing/server-side-public-license>. + * + * As a special exception, the copyright holders give permission to link the + * code of portions of this program with the OpenSSL library under certain + * conditions as described in each individual source file and distribute + * linked combinations including the program with the OpenSSL library. You + * must comply with the Server Side Public License in all respects for + * all of the code used other than as permitted herein. If you modify file(s) + * with this exception, you may extend this exception to your version of the + * file(s), but you are not obligated to do so. If you do not wish to do so, + * delete this exception statement from your version. If you delete this + * exception statement from all source files in the program, then also delete + * it in the license file. + */ + +#pragma once + +#include "mongo/db/query/optimizer/node.h" + + +namespace mongo::optimizer { + +ABT wrapConstFilter(ABT node); +ABT unwrapConstFilter(ABT node); + +} // namespace mongo::optimizer |