From 27ad45db503dc8f5d0829cf8eef59bf2bcf90bba Mon Sep 17 00:00:00 2001 From: Dmitry Orlov Date: Thu, 18 Apr 2024 19:34:18 +0300 Subject: [PATCH] Add specific statistic --- ydb/library/yql/core/yql_statistics.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ydb/library/yql/core/yql_statistics.h b/ydb/library/yql/core/yql_statistics.h index e92473fb2791..5d2c6a1c91df 100644 --- a/ydb/library/yql/core/yql_statistics.h +++ b/ydb/library/yql/core/yql_statistics.h @@ -13,6 +13,12 @@ enum EStatisticsType : ui32 { ManyManyJoin }; +// Providers may subclass this struct to associate specific statistics, useful to +// derive stats for higher-level operators in the plan. +struct IProviderStatistics { + virtual ~IProviderStatistics() {} +}; + /** * Optimizer Statistics struct records per-table and per-column statistics * for the current operator in the plan. Currently, only Nrows and Ncols are @@ -28,6 +34,7 @@ struct TOptimizerStatistics { double Cost = 0; double Selectivity = 1.0; const TVector& KeyColumns; + const IProviderStatistics* Specific = nullptr; TOptimizerStatistics() : KeyColumns(EmptyColumns) {} TOptimizerStatistics(double nrows, int ncols): Nrows(nrows), Ncols(ncols), KeyColumns(EmptyColumns) {} @@ -36,6 +43,8 @@ struct TOptimizerStatistics { TOptimizerStatistics(EStatisticsType type, double nrows, int ncols, double byteSize, double cost): Type(type), Nrows(nrows), Ncols(ncols), ByteSize(byteSize), Cost(cost), KeyColumns(EmptyColumns) {} TOptimizerStatistics(EStatisticsType type, double nrows, int ncols, double cost, const TVector& keyColumns): Type(type), Nrows(nrows), Ncols(ncols), Cost(cost), KeyColumns(keyColumns) {} TOptimizerStatistics(EStatisticsType type, double nrows, int ncols, double byteSize, double cost, const TVector& keyColumns): Type(type), Nrows(nrows), Ncols(ncols), ByteSize(byteSize), Cost(cost), KeyColumns(keyColumns) {} + TOptimizerStatistics(EStatisticsType type, double nrows, int ncols, double byteSize, double cost, const TVector& keyColumns, IProviderStatistics* specific) + : Type(type), Nrows(nrows), Ncols(ncols), ByteSize(byteSize), Cost(cost), KeyColumns(keyColumns), Specific(specific) {} TOptimizerStatistics& operator+=(const TOptimizerStatistics& other); bool Empty() const;