Skip to content

Commit 96be887

Browse files
committed
fix(kqp): use ReadTableRange instead LookupTable
1 parent 4fe7784 commit 96be887

File tree

2 files changed

+2
-42
lines changed

2 files changed

+2
-42
lines changed

ydb/core/kqp/opt/logical/kqp_opt_log_ranges.cpp

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -222,42 +222,19 @@ TExprBase KqpPushPredicateToReadTable(TExprBase node, TExprContext& ctx, const T
222222
fetches.reserve(lookup.GetKeyRanges().size());
223223

224224
for (auto& keyRange : lookup.GetKeyRanges()) {
225-
bool useDataOrGenericQueryLookup = false;
226225
bool useScanQueryLookup = false;
227226
if (onlyPointRanges && !IsPointPrefix(keyRange)) {
228227
return node;
229228
}
230229
if (keyRange.IsEquiRange()) {
231230
bool isFullKey = keyRange.GetNumDefined() == tableDesc.Metadata->KeyColumnNames.size();
232-
233-
// NOTE: Use more efficient full key lookup implementation in datashard.
234-
// Consider using lookup for partial keys as well once better constant folding
235-
// is available, currently it can introduce redundant compute stage.
236-
useDataOrGenericQueryLookup = (kqpCtx.IsDataQuery() || kqpCtx.IsGenericQuery()) && isFullKey;
237231
useScanQueryLookup = kqpCtx.IsScanQuery() && isFullKey
238232
&& kqpCtx.Config->EnableKqpScanQueryStreamLookup;
239233
}
240234

241235
TMaybeNode<TExprBase> readInput;
242236
// TODO: Use single implementation for all kinds of queries.
243-
if (useDataOrGenericQueryLookup) {
244-
auto lookupKeys = BuildEquiRangeLookup(keyRange, tableDesc, read.Pos(), ctx);
245-
246-
if (indexName) {
247-
readInput = Build<TKqlLookupIndex>(ctx, read.Pos())
248-
.Table(read.Table())
249-
.LookupKeys(lookupKeys)
250-
.Columns(read.Columns())
251-
.Index(indexName.Cast())
252-
.Done();
253-
} else {
254-
readInput = Build<TKqlLookupTable>(ctx, read.Pos())
255-
.Table(read.Table())
256-
.LookupKeys(lookupKeys)
257-
.Columns(read.Columns())
258-
.Done();
259-
}
260-
} else if (useScanQueryLookup) {
237+
if (useScanQueryLookup) {
261238
YQL_ENSURE(kqpCtx.Config->EnableKqpScanQueryStreamLookup);
262239
auto lookupKeys = BuildEquiRangeLookup(keyRange, tableDesc, read.Pos(), ctx);
263240

ydb/core/kqp/opt/logical/kqp_opt_log_ranges_predext.cpp

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -384,13 +384,6 @@ TExprBase KqpPushExtractedPredicateToReadTable(TExprBase node, TExprContext& ctx
384384
.LookupKeys(keys)
385385
.Done();
386386
}
387-
} else {
388-
result = Build<TKqlLookupIndex>(ctx, node.Pos())
389-
.Table(read.Table())
390-
.Columns(read.Columns())
391-
.LookupKeys(keys)
392-
.Index(indexName.Cast())
393-
.Done();
394387
}
395388
} else {
396389
if (kqpCtx.IsScanQuery()) {
@@ -402,19 +395,13 @@ TExprBase KqpPushExtractedPredicateToReadTable(TExprBase node, TExprContext& ctx
402395
.LookupStrategy().Build(TKqpStreamLookupStrategyName)
403396
.Done();
404397
}
405-
} else {
406-
result = Build<TKqlLookupTable>(ctx, node.Pos())
407-
.Table(read.Table())
408-
.Columns(read.Columns())
409-
.LookupKeys(keys)
410-
.Done();
411398
}
412399
}
413400
};
414401

415402
if (buildResult.LiteralRange) {
416403
bool ispoint = buildResult.PointPrefixLen == tableDesc.Metadata->KeyColumnNames.size();
417-
if (ispoint) {
404+
if (ispoint && kqpCtx.IsScanQuery()) { // Use lookup table only for scan query
418405
TVector<TExprBase> structMembers;
419406
for (size_t i = 0; i < tableDesc.Metadata->KeyColumnNames.size(); ++i) {
420407
auto member = Build<TCoNameValueTuple>(ctx, node.Pos())
@@ -462,10 +449,6 @@ TExprBase KqpPushExtractedPredicateToReadTable(TExprBase node, TExprContext& ctx
462449
.Done();
463450
}
464451
}
465-
} else if (buildResult.PointPrefixLen == tableDesc.Metadata->KeyColumnNames.size()) {
466-
YQL_ENSURE(prefixPointsExpr);
467-
residualLambda = pointsExtractionResult.PrunedLambda;
468-
buildLookup(prefixPointsExpr, input);
469452
}
470453
}
471454

0 commit comments

Comments
 (0)