Skip to content

Commit dd3c880

Browse files
committed
Support progress stats for workload (#13725)
1 parent b11e50a commit dd3c880

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

include/ydb-cpp-sdk/client/query/client.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,10 @@ class TExecuteQueryPart : public TStreamPartStatus {
210210
const TResultSet& GetResultSet() const { return *ResultSet_; }
211211
TResultSet ExtractResultSet() { return std::move(*ResultSet_); }
212212

213+
bool HasStats() const { return Stats_.has_value(); }
213214
const std::optional<TExecStats>& GetStats() const { return Stats_; }
215+
TExecStats ExtractStats() const { return std::move(*Stats_); }
216+
214217
const std::optional<TTransaction>& GetTransaction() const { return Transaction_; }
215218

216219
TExecuteQueryPart(TStatus&& status, std::optional<TExecStats>&& queryStats, std::optional<TTransaction>&& tx)

include/ydb-cpp-sdk/client/query/query.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ struct TExecuteQuerySettings : public TRequestSettings<TExecuteQuerySettings> {
7676
FLUENT_SETTING_DEFAULT(EStatsMode, StatsMode, EStatsMode::None);
7777
FLUENT_SETTING_OPTIONAL(bool, ConcurrentResultSets);
7878
FLUENT_SETTING(std::string, ResourcePool);
79+
FLUENT_SETTING_OPTIONAL(std::chrono::milliseconds, StatsCollectPeriod);
7980
};
8081

8182
struct TBeginTxSettings : public TRequestSettings<TBeginTxSettings> {};

src/api/protos/ydb_query.proto

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,13 @@ message ExecuteQueryRequest {
174174
// Allows to set size limitation (in bytes) for one result part
175175
int64 response_part_limit_bytes = 9 [(Ydb.value) = "[0; 33554432]"];
176176

177-
string pool_id = 10; // Workload manager pool id
177+
// Workload manager pool id
178+
string pool_id = 10;
179+
180+
// Time interval for sending periodical query statistics.
181+
// When query statistics are enabled (stats_mode != STATS_MODE_NONE), by default statistics will be sent only once after query execution is finished.
182+
// In case when stats_period_ms is specified and is non-zero, query statistics will be additionally sent every stats_period_ms milliseconds beginning from the start of query execution.
183+
int64 stats_period_ms = 11 [(Ydb.value) = ">= 0"];
178184
}
179185

180186
message ResultSetMeta {

src/client/query/impl/exec_query.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,10 @@ TFuture<std::pair<TPlainStatus, TExecuteQueryProcessorPtr>> StreamExecuteQueryIm
246246
request.set_response_part_limit_bytes(*settings.OutputChunkMaxSize_);
247247
}
248248

249+
if (settings.StatsCollectPeriod_) {
250+
request.set_stats_period_ms((*settings.StatsCollectPeriod_).count());
251+
}
252+
249253
if (txControl.HasTx()) {
250254
auto requestTxControl = request.mutable_tx_control();
251255
requestTxControl->set_commit_tx(txControl.CommitTx_);

0 commit comments

Comments
 (0)