Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
433fdffc
C
ClickHouse
项目概览
2dot5
/
ClickHouse
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
ClickHouse
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
433fdffc
编写于
7月 11, 2020
作者:
A
Azat Khuzhin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add lifetime_rows/lifetime_bytes interface (exported via system.tables)
上级
84c93a6b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
44 addition
and
0 deletion
+44
-0
docs/en/operations/system-tables/tables.md
docs/en/operations/system-tables/tables.md
+4
-0
src/Storages/IStorage.h
src/Storages/IStorage.h
+10
-0
src/Storages/System/StorageSystemTables.cpp
src/Storages/System/StorageSystemTables.cpp
+30
-0
未找到文件。
docs/en/operations/system-tables/tables.md
浏览文件 @
433fdffc
...
...
@@ -46,4 +46,8 @@ This table contains the following columns (the column type is shown in brackets)
- If the table stores data on disk, returns used space on disk (i.e. compressed).
- If the table stores data in memory, returns approximated number of used bytes in memory.
-
`lifetime_rows`
(Nullable(UInt64)) - Total number of rows INSERTed since server start.
-
`lifetime_bytes`
(Nullable(UInt64)) - Total number of bytes INSERTed since server start.
The
`system.tables`
table is used in
`SHOW TABLES`
query implementation.
src/Storages/IStorage.h
浏览文件 @
433fdffc
...
...
@@ -460,6 +460,16 @@ public:
/// when considering in-memory blocks.
virtual
std
::
optional
<
UInt64
>
totalBytes
()
const
{
return
{};
}
/// Number of rows INSERTed since server start.
///
/// Does not takes underlying Storage (if any) into account.
virtual
std
::
optional
<
UInt64
>
lifetimeRows
()
const
{
return
{};
}
/// Number of bytes INSERTed since server start.
///
/// Does not takes underlying Storage (if any) into account.
virtual
std
::
optional
<
UInt64
>
lifetimeBytes
()
const
{
return
{};
}
private:
/// Lock required for alter queries (lockForAlter). Always taken for write
/// (actually can be replaced with std::mutex, but for consistency we use
...
...
src/Storages/System/StorageSystemTables.cpp
浏览文件 @
433fdffc
...
...
@@ -55,6 +55,8 @@ StorageSystemTables::StorageSystemTables(const std::string & name_)
{
"storage_policy"
,
std
::
make_shared
<
DataTypeString
>
()},
{
"total_rows"
,
std
::
make_shared
<
DataTypeNullable
>
(
std
::
make_shared
<
DataTypeUInt64
>
())},
{
"total_bytes"
,
std
::
make_shared
<
DataTypeNullable
>
(
std
::
make_shared
<
DataTypeUInt64
>
())},
{
"lifetime_rows"
,
std
::
make_shared
<
DataTypeNullable
>
(
std
::
make_shared
<
DataTypeUInt64
>
())},
{
"lifetime_bytes"
,
std
::
make_shared
<
DataTypeNullable
>
(
std
::
make_shared
<
DataTypeUInt64
>
())},
}));
setInMemoryMetadata
(
storage_metadata
);
}
...
...
@@ -223,6 +225,14 @@ protected:
// total_bytes
if
(
columns_mask
[
src_index
++
])
res_columns
[
res_index
++
]
->
insertDefault
();
// lifetime_rows
if
(
columns_mask
[
src_index
++
])
res_columns
[
res_index
++
]
->
insertDefault
();
// lifetime_bytes
if
(
columns_mask
[
src_index
++
])
res_columns
[
res_index
++
]
->
insertDefault
();
}
}
...
...
@@ -430,6 +440,26 @@ protected:
else
res_columns
[
res_index
++
]
->
insertDefault
();
}
if
(
columns_mask
[
src_index
++
])
{
assert
(
table
!=
nullptr
);
auto
lifetime_rows
=
table
->
lifetimeRows
();
if
(
lifetime_rows
)
res_columns
[
res_index
++
]
->
insert
(
*
lifetime_rows
);
else
res_columns
[
res_index
++
]
->
insertDefault
();
}
if
(
columns_mask
[
src_index
++
])
{
assert
(
table
!=
nullptr
);
auto
lifetime_bytes
=
table
->
lifetimeBytes
();
if
(
lifetime_bytes
)
res_columns
[
res_index
++
]
->
insert
(
*
lifetime_bytes
);
else
res_columns
[
res_index
++
]
->
insertDefault
();
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录