mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
Distributed: Implement totalBytes() (system.tables.total_bytes)
This commit is contained in:
parent
456cbaf747
commit
ce09b7ff89
@ -768,6 +768,14 @@ std::vector<StorageDistributedDirectoryMonitor::Status> StorageDistributed::getD
|
||||
return statuses;
|
||||
}
|
||||
|
||||
std::optional<UInt64> StorageDistributed::totalBytes(const Settings &) const
|
||||
{
|
||||
UInt64 total_bytes = 0;
|
||||
for (const auto & status : getDirectoryMonitorsStatuses())
|
||||
total_bytes += status.bytes_count;
|
||||
return total_bytes;
|
||||
}
|
||||
|
||||
size_t StorageDistributed::getShardCount() const
|
||||
{
|
||||
return getCluster()->getShardCount();
|
||||
|
@ -77,6 +77,7 @@ public:
|
||||
unsigned /*num_streams*/) override;
|
||||
|
||||
bool supportsParallelInsert() const override { return true; }
|
||||
std::optional<UInt64> totalBytes(const Settings &) const override;
|
||||
|
||||
BlockOutputStreamPtr write(const ASTPtr & query, const StorageMetadataPtr & /*metadata_snapshot*/, const Context & context) override;
|
||||
|
||||
|
@ -45,3 +45,7 @@ Check total_bytes/total_rows for Set
|
||||
Check total_bytes/total_rows for Join
|
||||
10240 50
|
||||
10240 100
|
||||
Check total_bytes/total_rows for Distributed
|
||||
0 \N
|
||||
629 \N
|
||||
0 \N
|
||||
|
@ -126,3 +126,20 @@ SELECT total_bytes, total_rows FROM system.tables WHERE name = 'check_system_tab
|
||||
INSERT INTO check_system_tables SELECT number+50 FROM numbers(50);
|
||||
SELECT total_bytes, total_rows FROM system.tables WHERE name = 'check_system_tables';
|
||||
DROP TABLE check_system_tables;
|
||||
|
||||
SELECT 'Check total_bytes/total_rows for Distributed';
|
||||
-- metrics updated only after distributed_directory_monitor_sleep_time_ms
|
||||
SET distributed_directory_monitor_sleep_time_ms=10;
|
||||
CREATE TABLE check_system_tables_null (key Int) Engine=Null();
|
||||
CREATE TABLE check_system_tables AS check_system_tables_null Engine=Distributed(test_shard_localhost, currentDatabase(), check_system_tables_null);
|
||||
SYSTEM STOP DISTRIBUTED SENDS check_system_tables;
|
||||
SELECT total_bytes, total_rows FROM system.tables WHERE name = 'check_system_tables';
|
||||
INSERT INTO check_system_tables SELECT * FROM numbers(1) SETTINGS prefer_localhost_replica=0;
|
||||
-- 1 second should guarantee metrics update
|
||||
-- XXX: but this is kind of quirk, way more better will be account this metrics without any delays.
|
||||
SELECT sleep(1) FORMAT Null;
|
||||
SELECT total_bytes, total_rows FROM system.tables WHERE name = 'check_system_tables';
|
||||
SYSTEM FLUSH DISTRIBUTED check_system_tables;
|
||||
SELECT total_bytes, total_rows FROM system.tables WHERE name = 'check_system_tables';
|
||||
DROP TABLE check_system_tables_null;
|
||||
DROP TABLE check_system_tables;
|
||||
|
Loading…
Reference in New Issue
Block a user