Skip to content
This repository was archived by the owner on Sep 27, 2019. It is now read-only.

Commit f5e8db1

Browse files
committed
Clear insert plan value_ vector after use. Fixes issue #1151.
Resolves large performance degradation of inserts, after inclusion of statement/plan cache.
1 parent 2b64904 commit f5e8db1

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

src/executor/plan_executor.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static void CompileAndExecutePlan(
6565
}
6666

6767
auto on_query_result =
68-
[&on_complete, &consumer](executor::ExecutionResult result) {
68+
[&on_complete, &consumer, plan](executor::ExecutionResult result) {
6969
std::vector<ResultValue> values;
7070
for (const auto &tuple : consumer.GetOutputTuples()) {
7171
for (uint32_t i = 0; i < tuple.tuple_.size(); i++) {
@@ -75,6 +75,7 @@ static void CompileAndExecutePlan(
7575
values.push_back(std::move(str));
7676
}
7777
}
78+
plan->ClearParameterValues();
7879
on_complete(result, std::move(values));
7980
};
8081

@@ -102,6 +103,7 @@ static void InterpretPlan(
102103
if (status != true) {
103104
result.m_result = ResultType::FAILURE;
104105
CleanExecutorTree(executor_tree.get());
106+
plan->ClearParameterValues();
105107
on_complete(result, std::move(values));
106108
return;
107109
}
@@ -131,6 +133,7 @@ static void InterpretPlan(
131133
result.m_processed = executor_context->num_processed;
132134
result.m_result = ResultType::SUCCESS;
133135
CleanExecutorTree(executor_tree.get());
136+
plan->ClearParameterValues();
134137
on_complete(result, std::move(values));
135138
}
136139

@@ -164,7 +167,7 @@ void PlanExecutor::ExecutePlan(
164167
* @return number of executed tuples and logical_tile_list
165168
*/
166169
int PlanExecutor::ExecutePlan(
167-
const planner::AbstractPlan *plan, const std::vector<type::Value> &params,
170+
planner::AbstractPlan *plan, const std::vector<type::Value> &params,
168171
std::vector<std::unique_ptr<executor::LogicalTile>> &logical_tile_list) {
169172
PL_ASSERT(plan != nullptr);
170173
LOG_TRACE("PlanExecutor Start with transaction");

src/include/executor/plan_executor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class PlanExecutor {
6666
*/
6767
// FIXME This should be removed when PelotonService is removed/rewritten
6868
static int ExecutePlan(
69-
const planner::AbstractPlan *plan, const std::vector<type::Value> &params,
69+
planner::AbstractPlan *plan, const std::vector<type::Value> &params,
7070
std::vector<std::unique_ptr<executor::LogicalTile>> &logical_tile_list);
7171
};
7272

src/include/planner/abstract_plan.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ class AbstractPlan : public Printable {
7878

7979
// Setting values of the parameters in the prepare statement
8080
virtual void SetParameterValues(std::vector<type::Value> *values);
81+
82+
// FIXME. Clear the value_ vector.
83+
virtual void ClearParameterValues() {};
8184

8285
// Get the estimated cardinality of this plan
8386
int GetCardinality() const { return estimated_cardinality_; }

src/include/planner/insert_plan.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ class InsertPlan : public AbstractPlan {
6969

7070
void SetParameterValues(std::vector<type::Value> *values) override;
7171

72+
/*
73+
* Clear the parameter values of the current insert. The plan may be
74+
* cached in the statement / plan cache and may be reused.
75+
*/
76+
void ClearParameterValues() { values_.clear(); }
77+
7278
storage::DataTable *GetTable() const { return target_table_; }
7379

7480
const planner::ProjectInfo *GetProjectInfo() const {

0 commit comments

Comments
 (0)