Skip to content

Commit

Permalink
YQL-16720: Skip hybrid for desc sort
Browse files Browse the repository at this point in the history
  • Loading branch information
mxkovalev committed Jan 24, 2024
1 parent f711ded commit 74dc0cc
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions ydb/library/yql/providers/yt/provider/yql_yt_dq_hybrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ class TYtDqHybridTransformer : public TOptimizeTransformerBase {
return !HasSettingsExcept(*operation.Ref().Child(4U), DqOpSupportedSettings);
}

bool HasDescOrderOutput(const TYtOutputOpBase& operation) const {
TYqlRowSpecInfo outRowSpec(operation.Output().Item(0).RowSpec());
return outRowSpec.IsSorted() && outRowSpec.HasAuxColumns();
}

std::optional<std::array<ui64, 2U>> CanReadHybrid(const TYtSection& section) const {
if (HasSettingsExcept(section.Settings().Ref(), DqReadSupportedSettings))
return std::nullopt;
Expand Down Expand Up @@ -266,6 +271,10 @@ class TYtDqHybridTransformer : public TOptimizeTransformerBase {
const auto chunksLimit = State_->Configuration->MaxChunksForDqRead.Get().GetOrElse(DEFAULT_MAX_CHUNKS_FOR_DQ_READ);
if (const auto stat = CanReadHybrid(sort.Input().Item(0))) {
if (stat->front() <= sizeLimit && stat->back() <= chunksLimit) {
if (HasDescOrderOutput(sort)) {
PushStat("HybridSkipDescSort");
return node;
}
YQL_CLOG(INFO, ProviderYt) << "Sort on DQ with equivalent input size " << stat->front() << " and " << stat->back() << " chunks.";
PushStat("HybridTry");
PushHybridStat("Try", node.Raw()->Content());
Expand All @@ -287,6 +296,10 @@ class TYtDqHybridTransformer : public TOptimizeTransformerBase {
const auto chunksLimit = State_->Configuration->MaxChunksForDqRead.Get().GetOrElse(DEFAULT_MAX_CHUNKS_FOR_DQ_READ);
if (const auto stat = CanReadHybrid(merge.Input().Item(0))) {
if (stat->front() <= sizeLimit && stat->back() <= chunksLimit) {
if (HasDescOrderOutput(merge)) {
PushStat("HybridSkipDescSort");
return node;
}
YQL_CLOG(INFO, ProviderYt) << "Merge on DQ with equivalent input size " << stat->front() << " and " << stat->back() << " chunks.";
PushStat("HybridTry");
PushHybridStat("Try", node.Raw()->Content());
Expand Down

0 comments on commit 74dc0cc

Please sign in to comment.