ClickHouse/src/DataStreams/ExecutionSpeedLimits.h

33 lines
855 B
C++
Raw Normal View History

2019-10-03 18:27:11 +00:00
#pragma once
#include <Poco/Timespan.h>
2020-09-15 09:55:57 +00:00
#include <common/types.h>
2020-01-27 16:58:25 +00:00
#include <DataStreams/SizeLimits.h>
2019-10-03 18:27:11 +00:00
namespace DB
{
/// Limits for query execution speed.
class ExecutionSpeedLimits
{
public:
2019-10-21 16:26:29 +00:00
/// For rows per second.
size_t min_execution_rps = 0;
size_t max_execution_rps = 0;
/// For bytes per second.
size_t min_execution_bps = 0;
size_t max_execution_bps = 0;
2019-10-03 18:27:11 +00:00
Poco::Timespan max_execution_time = 0;
/// Verify that the speed is not too low after the specified time has elapsed.
Poco::Timespan timeout_before_checking_execution_speed = 0;
2019-10-10 14:16:15 +00:00
/// Pause execution in case if speed limits were exceeded.
2020-04-22 05:39:31 +00:00
void throttle(size_t read_rows, size_t read_bytes, size_t total_rows_to_read, UInt64 total_elapsed_microseconds) const;
2020-01-27 16:58:25 +00:00
2020-04-22 05:39:31 +00:00
bool checkTimeLimit(UInt64 elapsed_ns, OverflowMode overflow_mode) const;
2019-10-03 18:27:11 +00:00
};
}