diff options
author | Ben Shteinfeld <ben.shteinfeld@mongodb.com> | 2022-08-17 21:16:10 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-08-17 23:52:54 +0000 |
commit | 43f9a78849f884bd01608ee5129eb7ac6df16b4f (patch) | |
tree | 7f1df7c36f0d4f16d987e2d9498b5e0edba414ce /src/mongo | |
parent | d798c5fd75a5854fb8fefc590280aa701fa5e420 (diff) | |
download | mongo-43f9a78849f884bd01608ee5129eb7ac6df16b4f.tar.gz |
SERVER-62760 Implement CQF Query Logging
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/db/commands/cqf/cqf_aggregate.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/curop.cpp | 14 | ||||
-rw-r--r-- | src/mongo/db/curop.h | 6 | ||||
-rw-r--r-- | src/mongo/db/curop_metrics.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/stats/counters.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/stats/counters.h | 37 |
6 files changed, 43 insertions, 22 deletions
diff --git a/src/mongo/db/commands/cqf/cqf_aggregate.cpp b/src/mongo/db/commands/cqf/cqf_aggregate.cpp index d8aefc60818..ae154cad112 100644 --- a/src/mongo/db/commands/cqf/cqf_aggregate.cpp +++ b/src/mongo/db/commands/cqf/cqf_aggregate.cpp @@ -30,6 +30,7 @@ #include "mongo/db/commands/cqf/cqf_aggregate.h" #include "mongo/db/commands/cqf/cqf_command_utils.h" +#include "mongo/db/curop.h" #include "mongo/db/exec/sbe/abt/abt_lower.h" #include "mongo/db/pipeline/abt/document_source_visitor.h" #include "mongo/db/pipeline/abt/match_expression_visitor.h" @@ -406,6 +407,9 @@ std::unique_ptr<PlanExecutor, PlanExecutor::Deleter> getSBEExecutorViaCascadesOp "Timeseries collections are not supported", !collection || !collection->getTimeseriesOptions()); + auto curOp = CurOp::get(opCtx); + curOp->debug().cqfUsed = true; + QueryHints queryHints = getHintsFromQueryKnobs(); PrefixId prefixId; diff --git a/src/mongo/db/curop.cpp b/src/mongo/db/curop.cpp index e30a068c6ca..23bb5ee9830 100644 --- a/src/mongo/db/curop.cpp +++ b/src/mongo/db/curop.cpp @@ -878,7 +878,9 @@ void OpDebug::report(OperationContext* opCtx, } if (classicEngineUsed) { - pAttrs->add("queryExecutionEngine", classicEngineUsed.value() ? "classic" : "sbe"); + pAttrs->add("queryFramework", classicEngineUsed.value() ? "classic" : "sbe"); + } else if (cqfUsed) { + pAttrs->add("queryFramework", "cqf"); } if (!errInfo.isOK()) { @@ -1047,7 +1049,9 @@ void OpDebug::append(OperationContext* opCtx, } if (classicEngineUsed) { - b.append("queryExecutionEngine", classicEngineUsed.value() ? "classic" : "sbe"); + b.append("queryFramework", classicEngineUsed.value() ? "classic" : "sbe"); + } else if (cqfUsed) { + b.append("queryFramework", "cqf"); } { @@ -1311,9 +1315,11 @@ std::function<BSONObj(ProfileFilter::Args)> OpDebug::appendStaged(StringSet requ } }); - addIfNeeded("queryExecutionEngine", [](auto field, auto args, auto& b) { + addIfNeeded("queryFramework", [](auto field, auto args, auto& b) { if (args.op.classicEngineUsed) { - b.append("queryExecutionEngine", args.op.classicEngineUsed.value() ? "classic" : "sbe"); + b.append("queryFramework", args.op.classicEngineUsed.value() ? "classic" : "sbe"); + } else if (args.op.cqfUsed) { + b.append("queryFramework", "cqf"); } }); diff --git a/src/mongo/db/curop.h b/src/mongo/db/curop.h index 15dcb2e0154..998f2400c73 100644 --- a/src/mongo/db/curop.h +++ b/src/mongo/db/curop.h @@ -263,13 +263,17 @@ public: boost::optional<uint32_t> queryHash; // Has a value if this operation is a query. True if the execution tree for the find part of the - // query was built using the classic query engine, false if it was built in SBE. + // query was built exclusively using the classic query engine, false if any part was built using + // SBE. boost::optional<bool> classicEngineUsed; // Has a value if this operation is an aggregation query. True if `DocumentSources` were // involved in the execution tree for this query, false if they were not. boost::optional<bool> documentSourceUsed; + // Indicates whether this operation used the common query framework (CQF). + bool cqfUsed{false}; + // Tracks whether an aggregation query has a lookup stage regardless of the engine used. bool pipelineUsesLookup{false}; diff --git a/src/mongo/db/curop_metrics.cpp b/src/mongo/db/curop_metrics.cpp index 728c79472de..c2d7365852c 100644 --- a/src/mongo/db/curop_metrics.cpp +++ b/src/mongo/db/curop_metrics.cpp @@ -70,7 +70,7 @@ void recordCurOpMetrics(OperationContext* opCtx) { lookupPushdownCounters.incrementLookupCounters(CurOp::get(opCtx)->debug()); - queryEngineCounters.incrementQueryEngineCounters(CurOp::get(opCtx)); + queryFrameworkCounters.incrementQueryEngineCounters(CurOp::get(opCtx)); } } // namespace mongo diff --git a/src/mongo/db/stats/counters.cpp b/src/mongo/db/stats/counters.cpp index fca895940da..44328202169 100644 --- a/src/mongo/db/stats/counters.cpp +++ b/src/mongo/db/stats/counters.cpp @@ -318,7 +318,7 @@ NetworkCounter networkCounter; AuthCounter authCounter; AggStageCounters aggStageCounters; DotsAndDollarsFieldsCounters dotsAndDollarsFieldsCounters; -QueryEngineCounters queryEngineCounters; +QueryFrameworkCounters queryFrameworkCounters; LookupPushdownCounters lookupPushdownCounters; OperatorCounters operatorCountersAggExpressions{"operatorCounters.expressions."}; diff --git a/src/mongo/db/stats/counters.h b/src/mongo/db/stats/counters.h index 0a6273e6fba..e4f12ce7d46 100644 --- a/src/mongo/db/stats/counters.h +++ b/src/mongo/db/stats/counters.h @@ -308,9 +308,9 @@ public: extern DotsAndDollarsFieldsCounters dotsAndDollarsFieldsCounters; -class QueryEngineCounters { +class QueryFrameworkCounters { public: - QueryEngineCounters() = default; + QueryFrameworkCounters() = default; void incrementQueryEngineCounters(CurOp* curop) { auto& debug = curop->debug(); @@ -336,25 +336,32 @@ public: sbeOnlyAggregationCounter.increment(); } } + } else if (debug.cqfUsed) { + if (cmdName == "find") { + cqfFindQueryCounter.increment(); + } else { + cqfAggregationQueryCounter.increment(); + } } } - // Query counters that record whether a find query was fully or partially executed in SBE, or - // fully executed using the classic engine. One or the other will always be incremented during a - // query. - CounterMetric sbeFindQueryCounter{"query.queryExecutionEngine.find.sbe"}; - CounterMetric classicFindQueryCounter{"query.queryExecutionEngine.find.classic"}; + // Query counters that record whether a find query was fully or partially executed in SBE, fully + // executed using the classic engine, or fully executed using the common query framework (CQF). + // One of these will always be incremented during a query. + CounterMetric sbeFindQueryCounter{"query.queryFramework.find.sbe"}; + CounterMetric classicFindQueryCounter{"query.queryFramework.find.classic"}; + CounterMetric cqfFindQueryCounter{"query.queryFramework.find.cqf"}; // Aggregation query counters that record whether an aggregation was fully or partially executed - // in DocumentSource (an sbe/classic hybrid plan), or fully pushed down to the sbe/classic - // layer. Only incremented during aggregations. - CounterMetric sbeOnlyAggregationCounter{"query.queryExecutionEngine.aggregate.sbeOnly"}; - CounterMetric classicOnlyAggregationCounter{"query.queryExecutionEngine.aggregate.classicOnly"}; - CounterMetric sbeHybridAggregationCounter{"query.queryExecutionEngine.aggregate.sbeHybrid"}; - CounterMetric classicHybridAggregationCounter{ - "query.queryExecutionEngine.aggregate.classicHybrid"}; + // in DocumentSource (an sbe/classic hybrid plan), fully pushed down to the sbe/classic layer, + // or executed using CQF. These are only incremented during aggregations. + CounterMetric sbeOnlyAggregationCounter{"query.queryFramework.aggregate.sbeOnly"}; + CounterMetric classicOnlyAggregationCounter{"query.queryFramework.aggregate.classicOnly"}; + CounterMetric sbeHybridAggregationCounter{"query.queryFramework.aggregate.sbeHybrid"}; + CounterMetric classicHybridAggregationCounter{"query.queryFramework.aggregate.classicHybrid"}; + CounterMetric cqfAggregationQueryCounter{"query.queryFramework.aggregate.cqf"}; }; -extern QueryEngineCounters queryEngineCounters; +extern QueryFrameworkCounters queryFrameworkCounters; class LookupPushdownCounters { public: |