diff --git a/src/catalog/src/system_schema/information_schema/region_statistics.rs b/src/catalog/src/system_schema/information_schema/region_statistics.rs index 8db6b860bf..bfeddc6c74 100644 --- a/src/catalog/src/system_schema/information_schema/region_statistics.rs +++ b/src/catalog/src/system_schema/information_schema/region_statistics.rs @@ -44,6 +44,7 @@ const DISK_SIZE: &str = "disk_size"; const MEMTABLE_SIZE: &str = "memtable_size"; const MANIFEST_SIZE: &str = "manifest_size"; const SST_SIZE: &str = "sst_size"; +const SST_NUM: &str = "sst_num"; const INDEX_SIZE: &str = "index_size"; const ENGINE: &str = "engine"; const REGION_ROLE: &str = "region_role"; @@ -87,6 +88,7 @@ impl InformationSchemaRegionStatistics { ColumnSchema::new(MEMTABLE_SIZE, ConcreteDataType::uint64_datatype(), true), ColumnSchema::new(MANIFEST_SIZE, ConcreteDataType::uint64_datatype(), true), ColumnSchema::new(SST_SIZE, ConcreteDataType::uint64_datatype(), true), + ColumnSchema::new(SST_NUM, ConcreteDataType::uint64_datatype(), true), ColumnSchema::new(INDEX_SIZE, ConcreteDataType::uint64_datatype(), true), ColumnSchema::new(ENGINE, ConcreteDataType::string_datatype(), true), ColumnSchema::new(REGION_ROLE, ConcreteDataType::string_datatype(), true), @@ -149,6 +151,7 @@ struct InformationSchemaRegionStatisticsBuilder { memtable_sizes: UInt64VectorBuilder, manifest_sizes: UInt64VectorBuilder, sst_sizes: UInt64VectorBuilder, + sst_nums: UInt64VectorBuilder, index_sizes: UInt64VectorBuilder, engines: StringVectorBuilder, region_roles: StringVectorBuilder, @@ -167,6 +170,7 @@ impl InformationSchemaRegionStatisticsBuilder { memtable_sizes: UInt64VectorBuilder::with_capacity(INIT_CAPACITY), manifest_sizes: UInt64VectorBuilder::with_capacity(INIT_CAPACITY), sst_sizes: UInt64VectorBuilder::with_capacity(INIT_CAPACITY), + sst_nums: UInt64VectorBuilder::with_capacity(INIT_CAPACITY), index_sizes: UInt64VectorBuilder::with_capacity(INIT_CAPACITY), engines: StringVectorBuilder::with_capacity(INIT_CAPACITY), region_roles: StringVectorBuilder::with_capacity(INIT_CAPACITY), @@ -197,6 +201,7 @@ impl InformationSchemaRegionStatisticsBuilder { (MEMTABLE_SIZE, &Value::from(region_stat.memtable_size)), (MANIFEST_SIZE, &Value::from(region_stat.manifest_size)), (SST_SIZE, &Value::from(region_stat.sst_size)), + (SST_NUM, &Value::from(region_stat.sst_num)), (INDEX_SIZE, &Value::from(region_stat.index_size)), (ENGINE, &Value::from(region_stat.engine.as_str())), (REGION_ROLE, &Value::from(region_stat.role.to_string())), @@ -215,6 +220,7 @@ impl InformationSchemaRegionStatisticsBuilder { self.memtable_sizes.push(Some(region_stat.memtable_size)); self.manifest_sizes.push(Some(region_stat.manifest_size)); self.sst_sizes.push(Some(region_stat.sst_size)); + self.sst_nums.push(Some(region_stat.sst_num)); self.index_sizes.push(Some(region_stat.index_size)); self.engines.push(Some(®ion_stat.engine)); self.region_roles.push(Some(®ion_stat.role.to_string())); @@ -230,6 +236,7 @@ impl InformationSchemaRegionStatisticsBuilder { Arc::new(self.memtable_sizes.finish()), Arc::new(self.manifest_sizes.finish()), Arc::new(self.sst_sizes.finish()), + Arc::new(self.sst_nums.finish()), Arc::new(self.index_sizes.finish()), Arc::new(self.engines.finish()), Arc::new(self.region_roles.finish()), diff --git a/src/cmd/src/standalone.rs b/src/cmd/src/standalone.rs index a4328b5132..655bbd6661 100644 --- a/src/cmd/src/standalone.rs +++ b/src/cmd/src/standalone.rs @@ -821,6 +821,7 @@ impl InformationExtension for StandaloneInformationExtension { memtable_size: region_stat.memtable_size, manifest_size: region_stat.manifest_size, sst_size: region_stat.sst_size, + sst_num: region_stat.sst_num, index_size: region_stat.index_size, region_manifest: region_stat.manifest.into(), data_topic_latest_entry_id: region_stat.data_topic_latest_entry_id, diff --git a/src/common/meta/src/datanode.rs b/src/common/meta/src/datanode.rs index bee7f989c6..1db59b7c8e 100644 --- a/src/common/meta/src/datanode.rs +++ b/src/common/meta/src/datanode.rs @@ -93,6 +93,8 @@ pub struct RegionStat { pub manifest_size: u64, /// The size of the SST data files in bytes. pub sst_size: u64, + /// The num of the SST data files. + pub sst_num: u64, /// The size of the SST index files in bytes. pub index_size: u64, /// The manifest infoof the region. @@ -173,8 +175,8 @@ impl RegionStat { std::mem::size_of::() + // rcus, wcus, approximate_bytes, num_rows std::mem::size_of::() * 4 + - // memtable_size, manifest_size, sst_size, index_size - std::mem::size_of::() * 4 + + // memtable_size, manifest_size, sst_size, sst_num, index_size + std::mem::size_of::() * 5 + // engine std::mem::size_of::() + self.engine.capacity() + // region_manifest @@ -275,6 +277,7 @@ impl From<&api::v1::meta::RegionStat> for RegionStat { memtable_size: region_stat.memtable_size, manifest_size: region_stat.manifest_size, sst_size: region_stat.sst_size, + sst_num: region_stat.sst_num, index_size: region_stat.index_size, region_manifest: region_stat.manifest.into(), data_topic_latest_entry_id: region_stat.data_topic_latest_entry_id, diff --git a/src/meta-srv/src/handler/collect_leader_region_handler.rs b/src/meta-srv/src/handler/collect_leader_region_handler.rs index 13aee5d234..695d77ce62 100644 --- a/src/meta-srv/src/handler/collect_leader_region_handler.rs +++ b/src/meta-srv/src/handler/collect_leader_region_handler.rs @@ -121,6 +121,7 @@ mod tests { memtable_size: 0, manifest_size: 0, sst_size: 0, + sst_num: 0, index_size: 0, data_topic_latest_entry_id: 0, metadata_topic_latest_entry_id: 0, diff --git a/src/meta-srv/src/handler/failure_handler.rs b/src/meta-srv/src/handler/failure_handler.rs index cdcd9d3228..9530d0d128 100644 --- a/src/meta-srv/src/handler/failure_handler.rs +++ b/src/meta-srv/src/handler/failure_handler.rs @@ -97,6 +97,7 @@ mod tests { memtable_size: 0, manifest_size: 0, sst_size: 0, + sst_num: 0, index_size: 0, region_manifest: RegionManifestInfo::Mito { manifest_version: 0, diff --git a/src/meta-srv/src/handler/region_lease_handler.rs b/src/meta-srv/src/handler/region_lease_handler.rs index c133a54798..311b101103 100644 --- a/src/meta-srv/src/handler/region_lease_handler.rs +++ b/src/meta-srv/src/handler/region_lease_handler.rs @@ -159,6 +159,7 @@ mod test { memtable_size: 0, manifest_size: 0, sst_size: 0, + sst_num: 0, index_size: 0, region_manifest: RegionManifestInfo::Mito { manifest_version: 0, diff --git a/src/meta-srv/src/selector/weight_compute.rs b/src/meta-srv/src/selector/weight_compute.rs index d69e2f56d3..ab16c5f27c 100644 --- a/src/meta-srv/src/selector/weight_compute.rs +++ b/src/meta-srv/src/selector/weight_compute.rs @@ -190,6 +190,7 @@ mod tests { memtable_size: 0, manifest_size: 0, sst_size: 0, + sst_num: 0, index_size: 0, region_manifest: RegionManifestInfo::Mito { manifest_version: 0, @@ -217,6 +218,7 @@ mod tests { memtable_size: 0, manifest_size: 0, sst_size: 0, + sst_num: 0, index_size: 0, region_manifest: RegionManifestInfo::Mito { manifest_version: 0, @@ -244,6 +246,7 @@ mod tests { memtable_size: 0, manifest_size: 0, sst_size: 0, + sst_num: 0, index_size: 0, region_manifest: RegionManifestInfo::Mito { manifest_version: 0, diff --git a/src/metric-engine/src/utils.rs b/src/metric-engine/src/utils.rs index 0f28a6365e..4744d0b49d 100644 --- a/src/metric-engine/src/utils.rs +++ b/src/metric-engine/src/utils.rs @@ -54,6 +54,7 @@ pub fn get_region_statistic(mito: &MitoEngine, region_id: RegionId) -> Option u64 { + self.levels + .iter() + .map(|level_meta| level_meta.files.len() as u64) + .sum() + } + /// Returns SST data files'space occupied in current version. pub(crate) fn sst_usage(&self) -> u64 { self.levels diff --git a/src/store-api/src/region_engine.rs b/src/store-api/src/region_engine.rs index 3cf9bb0fc1..25951a4f6d 100644 --- a/src/store-api/src/region_engine.rs +++ b/src/store-api/src/region_engine.rs @@ -444,6 +444,8 @@ pub struct RegionStatistic { pub manifest_size: u64, /// The size of SST data files in bytes. pub sst_size: u64, + /// The num of SST files. + pub sst_num: u64, /// The size of SST index files in bytes. #[serde(default)] pub index_size: u64, diff --git a/tests/cases/standalone/common/system/information_schema.result b/tests/cases/standalone/common/system/information_schema.result index 85eb99f2a3..af8533572d 100644 --- a/tests/cases/standalone/common/system/information_schema.result +++ b/tests/cases/standalone/common/system/information_schema.result @@ -318,14 +318,15 @@ select * from information_schema.columns order by table_schema, table_name, colu | greptime | information_schema | region_peers | table_name | 3 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | No | string | | | | greptime | information_schema | region_peers | table_schema | 2 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | No | string | | | | greptime | information_schema | region_statistics | disk_size | 5 | | | 20 | 0 | | | | | | select,insert | | UInt64 | bigint unsigned | FIELD | | Yes | bigint unsigned | | | -| greptime | information_schema | region_statistics | engine | 10 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | Yes | string | | | -| greptime | information_schema | region_statistics | index_size | 9 | | | 20 | 0 | | | | | | select,insert | | UInt64 | bigint unsigned | FIELD | | Yes | bigint unsigned | | | +| greptime | information_schema | region_statistics | engine | 11 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | Yes | string | | | +| greptime | information_schema | region_statistics | index_size | 10 | | | 20 | 0 | | | | | | select,insert | | UInt64 | bigint unsigned | FIELD | | Yes | bigint unsigned | | | | greptime | information_schema | region_statistics | manifest_size | 7 | | | 20 | 0 | | | | | | select,insert | | UInt64 | bigint unsigned | FIELD | | Yes | bigint unsigned | | | | greptime | information_schema | region_statistics | memtable_size | 6 | | | 20 | 0 | | | | | | select,insert | | UInt64 | bigint unsigned | FIELD | | Yes | bigint unsigned | | | | greptime | information_schema | region_statistics | region_id | 1 | | | 20 | 0 | | | | | | select,insert | | UInt64 | bigint unsigned | FIELD | | No | bigint unsigned | | | | greptime | information_schema | region_statistics | region_number | 3 | | | 10 | 0 | | | | | | select,insert | | UInt32 | int unsigned | FIELD | | No | int unsigned | | | -| greptime | information_schema | region_statistics | region_role | 11 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | Yes | string | | | +| greptime | information_schema | region_statistics | region_role | 12 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | Yes | string | | | | greptime | information_schema | region_statistics | region_rows | 4 | | | 20 | 0 | | | | | | select,insert | | UInt64 | bigint unsigned | FIELD | | Yes | bigint unsigned | | | +| greptime | information_schema | region_statistics | sst_num | 9 | | | 20 | 0 | | | | | | select,insert | | UInt64 | bigint unsigned | FIELD | | Yes | bigint unsigned | | | | greptime | information_schema | region_statistics | sst_size | 8 | | | 20 | 0 | | | | | | select,insert | | UInt64 | bigint unsigned | FIELD | | Yes | bigint unsigned | | | | greptime | information_schema | region_statistics | table_id | 2 | | | 10 | 0 | | | | | | select,insert | | UInt32 | int unsigned | FIELD | | No | int unsigned | | | | greptime | information_schema | routines | character_maximum_length | 7 | | | 19 | 0 | | | | | | select,insert | | Int64 | bigint | FIELD | | No | bigint | | |