diff --git a/src/query/interpreter.cpp b/src/query/interpreter.cpp index 229e0c7ca..e0d6bd75d 100644 --- a/src/query/interpreter.cpp +++ b/src/query/interpreter.cpp @@ -89,10 +89,6 @@ Interpreter::Results Interpreter::operator()( ctx.symbol_table_, std::move(ast_storage)); } - if (FLAGS_query_plan_cache) { - plan = plan_cache_.access().insert(stripped.hash(), plan).first->second; - } - // Dispatch plans to workers (if we have any for them). if (plan->distributed_plan().worker_plan) { auto &dispatcher = db_accessor.db().plan_dispatcher(); @@ -100,6 +96,12 @@ Interpreter::Results Interpreter::operator()( plan->distributed_plan().worker_plan, plan->symbol_table()); } + + if (FLAGS_query_plan_cache) { + // TODO: If the same plan was already cached, invalidate the dispatched + // plan (above) from workers. + plan = plan_cache_.access().insert(stripped.hash(), plan).first->second; + } } auto *logical_plan = &plan->plan();