Skip to content

Commit d84a0c9

Browse files
authored
fix allow single partition optimization (#1212)
1 parent 50a1147 commit d84a0c9

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

ydb/core/kqp/executer_actor/kqp_data_executer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2206,13 +2206,13 @@ class TKqpDataExecuter : public TKqpExecuterBase<TKqpDataExecuter, EExecType::Da
22062206
}
22072207
}
22082208

2209-
const bool enableOptForTasks = !UnknownAffectedShardCount && !HasExternalSources;
2209+
const bool singlePartitionOptAllowed = !UnknownAffectedShardCount && !HasExternalSources && (DatashardTxs.size() == 0);
22102210
const bool useDataQueryPool = !(HasExternalSources && DatashardTxs.size() == 0);
22112211
const bool localComputeTasks = !((HasExternalSources || HasOlapTable || HasDatashardSourceScan) && DatashardTxs.size() == 0);
22122212

22132213
Planner = CreateKqpPlanner(TasksGraph, TxId, SelfId(), GetSnapshot(),
22142214
Database, UserToken, Deadline.GetOrElse(TInstant::Zero()), Request.StatsMode, false, Nothing(),
2215-
ExecuterSpan, std::move(ResourceSnapshot), ExecuterRetriesConfig, useDataQueryPool, localComputeTasks, Request.MkqlMemoryLimit, AsyncIoFactory, enableOptForTasks, GetUserRequestContext());
2215+
ExecuterSpan, std::move(ResourceSnapshot), ExecuterRetriesConfig, useDataQueryPool, localComputeTasks, Request.MkqlMemoryLimit, AsyncIoFactory, singlePartitionOptAllowed, GetUserRequestContext());
22162216

22172217
auto err = Planner->PlanExecution();
22182218
if (err) {

ydb/core/kqp/executer_actor/kqp_planner.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ TKqpPlanner::TKqpPlanner(TKqpTasksGraph& graph, ui64 txId, const TActorId& execu
6464
TVector<NKikimrKqp::TKqpNodeResources>&& resourcesSnapshot,
6565
const NKikimrConfig::TTableServiceConfig::TExecuterRetriesConfig& executerRetriesConfig,
6666
bool useDataQueryPool, bool localComputeTasks, ui64 mkqlMemoryLimit, NYql::NDq::IDqAsyncIoFactory::TPtr asyncIoFactory,
67-
bool doOptimization, const TIntrusivePtr<TUserRequestContext>& userRequestContext)
67+
bool allowSinglePartitionOpt, const TIntrusivePtr<TUserRequestContext>& userRequestContext)
6868
: TxId(txId)
6969
, ExecuterId(executer)
7070
, Snapshot(snapshot)
@@ -82,7 +82,7 @@ TKqpPlanner::TKqpPlanner(TKqpTasksGraph& graph, ui64 txId, const TActorId& execu
8282
, LocalComputeTasks(localComputeTasks)
8383
, MkqlMemoryLimit(mkqlMemoryLimit)
8484
, AsyncIoFactory(asyncIoFactory)
85-
, DoOptimization(doOptimization)
85+
, AllowSinglePartitionOpt(allowSinglePartitionOpt)
8686
, UserRequestContext(userRequestContext)
8787
{
8888
if (!Database) {
@@ -410,7 +410,7 @@ std::unique_ptr<IEventHandle> TKqpPlanner::PlanExecution() {
410410
ComputeTasks.clear();
411411
}
412412

413-
if (nComputeTasks == 0 && TasksPerNode.size() == 1 && (AsyncIoFactory != nullptr) && DoOptimization && LocalComputeTasks) {
413+
if (nComputeTasks == 0 && TasksPerNode.size() == 1 && (AsyncIoFactory != nullptr) && AllowSinglePartitionOpt) {
414414
// query affects a single key or shard, so it might be more effective
415415
// to execute this task locally so we can avoid useless overhead for remote task launching.
416416
for (auto& [shardId, tasks]: TasksPerNode) {

ydb/core/kqp/executer_actor/kqp_planner.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class TKqpPlanner {
4646
const Ydb::Table::QueryStatsCollection::Mode& statsMode,
4747
bool withSpilling, const TMaybe<NKikimrKqp::TRlPath>& rlPath, NWilson::TSpan& ExecuterSpan,
4848
TVector<NKikimrKqp::TKqpNodeResources>&& resourcesSnapshot, const NKikimrConfig::TTableServiceConfig::TExecuterRetriesConfig& executerRetriesConfig,
49-
bool useDataQueryPool, bool localComputeTasks, ui64 mkqlMemoryLimit, NYql::NDq::IDqAsyncIoFactory::TPtr asyncIoFactory, bool doOptimization,
49+
bool useDataQueryPool, bool localComputeTasks, ui64 mkqlMemoryLimit, NYql::NDq::IDqAsyncIoFactory::TPtr asyncIoFactory, bool allowSinglePartitionOpt,
5050
const TIntrusivePtr<TUserRequestContext>& userRequestContext);
5151

5252
bool SendStartKqpTasksRequest(ui32 requestId, const TActorId& target);
@@ -100,7 +100,7 @@ class TKqpPlanner {
100100
NYql::NDq::IDqAsyncIoFactory::TPtr AsyncIoFactory;
101101
ui32 nComputeTasks = 0;
102102
ui32 nScanTasks = 0;
103-
bool DoOptimization;
103+
bool AllowSinglePartitionOpt;
104104

105105
THashMap<TActorId, TProgressStat> PendingComputeActors; // Running compute actors (pure and DS)
106106
THashSet<ui64> PendingComputeTasks; // Not started yet, waiting resources

0 commit comments

Comments
 (0)