安全管理-权限日志,如何统计空间使用情况

栏目:云苍穹知识作者:金蝶来源:金蝶云社区发布:2024-09-23浏览:1

安全管理-权限日志,如何统计空间使用情况

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)权限风控小助手之权限日志权限日志

(2)安全管理-权限日志,如何设置归档时长

安全管理-权限日志,如何统计空间使用情况

1 问题描述如何知晓系统使用权限日志,占用了多少数据库磁盘空间?2 解决方法使用数据库客户端,在日志库进行查询。MYSQL库查出权限日志...
点击下载文档
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息