Skip to content

Commit 4a9ebb4

Browse files
authored
[NEW RBO] Use canonical statistic names (#37981)
1 parent 0e70370 commit 4a9ebb4

3 files changed

Lines changed: 19 additions & 19 deletions

File tree

ydb/core/kqp/opt/rbo/kqp_rbo_compute_statistics.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ void TOpEmptySource::ComputeStatistics(TRBOContext& ctx, TPlanProps& planProps)
104104
Y_UNUSED(planProps);
105105
Y_ENSURE(Props.Metadata.has_value());
106106
Props.Statistics = TRBOStatistics();
107-
Props.Statistics->RecordsCount = 1;
108-
Props.Statistics->DataSize = 1;
107+
Props.Statistics->ERows = 1;
108+
Props.Statistics->EBytes = 1;
109109
Props.Cost = 0;
110110
}
111111

@@ -175,8 +175,8 @@ void TOpRead::ComputeStatistics(TRBOContext& ctx, TPlanProps& planProps) {
175175
const auto& tableData = ctx.KqpCtx.Tables->ExistingTable(ctx.KqpCtx.Cluster, path.Value());
176176

177177
Props.Statistics = TRBOStatistics();
178-
Props.Statistics->RecordsCount = tableData.Metadata->RecordsCount;
179-
Props.Statistics->DataSize = tableData.Metadata->DataSize;
178+
Props.Statistics->ERows = tableData.Metadata->RecordsCount;
179+
Props.Statistics->EBytes = tableData.Metadata->DataSize;
180180
Props.Cost = 0;
181181
}
182182

@@ -198,7 +198,7 @@ void TOpFilter::ComputeStatistics(TRBOContext& ctx, TPlanProps& planProps) {
198198
double selectivity = TPredicateSelectivityComputer(inputStats).Compute(lambda.Body());
199199

200200
double filterSelectivity = selectivity * Props.Statistics->Selectivity;
201-
Props.Statistics->DataSize = filterSelectivity * Props.Statistics->DataSize;
201+
Props.Statistics->EBytes = filterSelectivity * Props.Statistics->EBytes;
202202
Props.Statistics->Selectivity = filterSelectivity;
203203
}
204204

@@ -275,14 +275,14 @@ void TOpMap::ComputeStatistics(TRBOContext& ctx, TPlanProps& planProps) {
275275

276276
const auto inputColumnsCount = GetInput()->Props.Metadata->ColumnsCount;
277277
if (Props.Metadata->ColumnsCount != inputColumnsCount) {
278-
double inputDataSize = Props.Statistics->DataSize;
278+
double inputDataSize = Props.Statistics->EBytes;
279279
if (inputColumnsCount!=0) {
280-
Props.Statistics->DataSize = inputDataSize * Props.Metadata->ColumnsCount / (double)inputColumnsCount;
280+
Props.Statistics->EBytes = inputDataSize * Props.Metadata->ColumnsCount / (double)inputColumnsCount;
281281
}
282282
// Input may have 0 columns (e.g. EmptySource), in such case the data size depends on the number of records
283283
// and the number of columns in the output. We just assume each column contains 8 bytes
284284
else {
285-
Props.Statistics->DataSize = Props.Statistics->RecordsCount * Props.Metadata->ColumnsCount * 8;
285+
Props.Statistics->EBytes = Props.Statistics->ERows * Props.Metadata->ColumnsCount * 8;
286286
}
287287
}
288288
}
@@ -328,8 +328,8 @@ void TOpAggregate::ComputeStatistics(TRBOContext& ctx, TPlanProps& planProps) {
328328

329329
const auto inputColumnsCount = GetInput()->Props.Metadata->ColumnsCount;
330330
if (Props.Metadata->ColumnsCount != inputColumnsCount) {
331-
double inputDataSize = Props.Statistics->DataSize;
332-
Props.Statistics->DataSize = inputDataSize * Props.Metadata->ColumnsCount / (double)inputColumnsCount;
331+
double inputDataSize = Props.Statistics->EBytes;
332+
Props.Statistics->EBytes = inputDataSize * Props.Metadata->ColumnsCount / (double)inputColumnsCount;
333333
}
334334
}
335335

@@ -435,8 +435,8 @@ void TOpJoin::ComputeStatistics(TRBOContext& ctx, TPlanProps& planProps) {
435435
false,
436436
FindCardHint(unionOfAliases, *hints.BytesHints));
437437

438-
Props.Statistics->DataSize = CBOStats.ByteSize;
439-
Props.Statistics->RecordsCount = CBOStats.Nrows;
438+
Props.Statistics->EBytes = CBOStats.ByteSize;
439+
Props.Statistics->ERows = CBOStats.Nrows;
440440
Props.Statistics->Selectivity = CBOStats.Selectivity;
441441

442442
if (Props.JoinAlgo.has_value()) {
@@ -465,8 +465,8 @@ void TOpUnionAll::ComputeStatistics(TRBOContext& ctx, TPlanProps& planProps) {
465465
}
466466

467467
Props.Statistics = TRBOStatistics();
468-
Props.Statistics->DataSize = GetLeftInput()->Props.Statistics->DataSize + GetRightInput()->Props.Statistics->DataSize;
469-
Props.Statistics->RecordsCount = GetLeftInput()->Props.Statistics->RecordsCount + GetRightInput()->Props.Statistics->RecordsCount;
468+
Props.Statistics->EBytes = GetLeftInput()->Props.Statistics->EBytes + GetRightInput()->Props.Statistics->EBytes;
469+
Props.Statistics->ERows = GetLeftInput()->Props.Statistics->ERows + GetRightInput()->Props.Statistics->ERows;
470470

471471
if (GetLeftInput()->Props.Cost.has_value() && GetRightInput()->Props.Cost.has_value()) {
472472
Props.Cost = *GetLeftInput()->Props.Cost + *GetRightInput()->Props.Cost;

ydb/core/kqp/opt/rbo/kqp_rbo_statistics.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ TOptimizerStatistics BuildOptimizerStatistics(TPhysicalOpProps& props, bool with
7272
const double cost = props.Cost.has_value() ? *props.Cost : 0.0;
7373

7474
return TOptimizerStatistics(props.Metadata->Type,
75-
withStatsAndCosts ? props.Statistics->DataSize : 0.0,
75+
withStatsAndCosts ? props.Statistics->EBytes : 0.0,
7676
props.Metadata->ColumnsCount,
77-
withStatsAndCosts ? props.Statistics->DataSize : 0.0,
77+
withStatsAndCosts ? props.Statistics->EBytes : 0.0,
7878
withStatsAndCosts ? cost : 0.0,
7979
TIntrusivePtr<TOptimizerStatistics::TKeyColumns>(
8080
new TOptimizerStatistics::TKeyColumns(keyColumnNames)));
@@ -145,7 +145,7 @@ TString TRBOMetadata::ToString(ui32 printOptions) {
145145

146146
TString TRBOStatistics::ToString(ui32 printOptions) {
147147
Y_UNUSED(printOptions);
148-
return TStringBuilder() << "N records: " << RecordsCount << ", Size: " << DataSize << ", Selectivity: " << Selectivity;
148+
return TStringBuilder() << "N records: " << ERows << ", Size: " << EBytes << ", Selectivity: " << Selectivity;
149149
}
150150

151151
}

ydb/core/kqp/opt/rbo/kqp_rbo_statistics.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ class TRBOMetadata {
9393

9494
class TRBOStatistics {
9595
public:
96-
double RecordsCount = 0;
97-
double DataSize = 0;
96+
double ERows = 0;
97+
double EBytes = 0;
9898
double Selectivity = 1.0;
9999

100100
TString ToString(ui32 printOptions);

0 commit comments

Comments
 (0)