1. 查看指定数据库各表容量大小
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)'
from information_schema.tables
where table_schema='mysql'
order by data_length desc, index_length desc;
2.千万级数据删除
2.1.创建临时表,将不需要删除数据放过去
CREATE TABLE user_game_log_old SELECT * FROM user_game_log where cts>1619798400000;
2.2 截断表
TRUNCATE TABLE user_game_log;
2.3 .备份的数据插入到表中
INSERT INTO user_game_log SELECT * FROM user_game_log_old;