Home  >  Article  >  Backend Development  >  mysql删除数据

mysql删除数据

WBOY
WBOYOriginal
2016-06-06 20:16:391239browse

有一个正在线上使用的、亿级别数据量的mysql数据表,现在发现有90%的数据是无效的。现在想删除这部分数据,以节省磁盘空间。有什么比较好的方案?

回复内容:

有一个正在线上使用的、亿级别数据量的mysql数据表,现在发现有90%的数据是无效的。现在想删除这部分数据,以节省磁盘空间。有什么比较好的方案?

1.取到无效数据的索引,分别放到N个数组中,定期分批清理,完成后优化下该表。
2.取到有效数据的索引,将有效数据copy到新的表中,copy完成后,将旧表删除,新表更名。

1.确定无效数据的判断条件;
2.取得所有表名;
3.循环删除无效信息;

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn