安全管理-权限日志,如何统计空间使用情况
1 问题描述
如何知晓系统使用权限日志,占用了多少数据库磁盘空间?
2 解决方法
使用数据库客户端,在日志库进行查询。
MYSQL库
查出权限日志所有表(包含索引)占用空间:
select concat(round(sum(data_length/1024/1024),2),'MB') as '数据+索引容量(MB)' from information_schema.tables where table_schema='ptest_biz_baseline_log' and table_name like 't_perm_log%';
查看权限日志各表占用空间:
select table_schema as '数据库', table_name as '表名', table_rows as '记录数', truncate(data_length/1024/1024, 2) as '数据容量(MB)', truncate(index_length/1024/1024, 2) as '索引容量(MB)', (truncate(data_length/1024/1024, 2) + truncate(index_length/1024/1024, 2)) as '总容量(MB)' from information_schema.tables where table_schema='ptest_biz_baseline_log' and table_name like 't_perm_log%' order by (truncate(data_length/1024/1024, 2) + truncate(index_length/1024/1024, 2)) desc;
PS:ptest_biz_baseline_log 为 数据库的库名。
PostgrelSQL
查出权限日志所有表(包含索引)占用空间:
select pg_size_pretty(sum(t.size)) from ( SELECT pg_total_relation_size('"' || table_schema || '"."' || table_name || '"')AS size FROM information_schema.tables where table_name like 't_perm_log%' or table_name like 't_permlog%' ) t;
查出权限日志各表占用空间,按大小排序并分离data与index:
SELECT table_name, pg_size_pretty(table_size) AS table_size, pg_size_pretty(indexes_size) AS indexes_size, pg_size_pretty(total_size) AS total_size FROM ( SELECT table_name, pg_table_size(table_name) AS table_size, pg_indexes_size(table_name) AS indexes_size, pg_total_relation_size(table_name) AS total_size FROM ( SELECT ('"' || table_schema || '"."' || table_name || '"') AS table_name FROM information_schema.tables where table_name like 't_perm_log%' or table_name like 't_permlog%' ) AS all_tables ORDER BY total_size DESC ) AS pretty_sizes;
3 相关文档
(1)权限风控小助手之权限日志或权限日志
安全管理-权限日志,如何统计空间使用情况
1 问题描述如何知晓系统使用权限日志,占用了多少数据库磁盘空间?2 解决方法使用数据库客户端,在日志库进行查询。MYSQL库查出权限日志...
点击下载文档
上一篇:功能升级迭代追加授权方案下一篇:安全管理-权限日志,如何设置归档时长
本文2024-09-23 00:46:01发表“云苍穹知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-cangqiong-141593.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
热门文章