Skip to content
Snippets Groups Projects
Unverified Commit 55a2147b authored by Yee's avatar Yee Committed by GitHub
Browse files

Response optimization time to client (#796)

parent 0f2f0d02
No related branches found
No related tags found
No related merge requests found
......@@ -86,6 +86,7 @@ static size_t makePlanNodeDesc(const PlanNode* node, PlanDescription* planDesc)
void ExecutionPlan::fillPlanDescription(PlanDescription* planDesc) const {
DCHECK(planDesc != nullptr);
planDesc->optimize_time_in_us = optimizeTimeInUs_;
makePlanNodeDesc(root_, planDesc);
}
......
......@@ -34,9 +34,14 @@ public:
return root_;
}
int32_t* optimizeTimeInUs() {
return &optimizeTimeInUs_;
}
void fillPlanDescription(PlanDescription* planDesc) const;
private:
int32_t optimizeTimeInUs_{0};
int64_t id_{-1};
PlanNode* root_{nullptr};
};
......
......@@ -14,6 +14,7 @@
#include "planner/ExecutionPlan.h"
#include "planner/PlanNode.h"
#include "scheduler/Scheduler.h"
#include "util/ScopedTimer.h"
#include "validator/Validator.h"
#include "util/AstUtils.h"
#include "stats/StatsDef.h"
......@@ -67,10 +68,14 @@ Status QueryInstance::validateAndOptimize() {
NG_RETURN_IF_ERROR(Validator::validate(sentence_.get(), qctx()));
auto rootStatus = optimizer_->findBestPlan(qctx_.get());
NG_RETURN_IF_ERROR(rootStatus);
auto newRoot = std::move(rootStatus).value();
qctx_->setPlan(std::make_unique<ExecutionPlan>(const_cast<PlanNode *>(newRoot)));
auto plan = std::make_unique<ExecutionPlan>();
{
SCOPED_TIMER(plan->optimizeTimeInUs());
auto rootStatus = optimizer_->findBestPlan(qctx_.get());
NG_RETURN_IF_ERROR(rootStatus);
plan->setRoot(const_cast<PlanNode *>(std::move(rootStatus).value()));
}
qctx_->setPlan(std::move(plan));
return Status::OK();
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment