Home > Database > Mysql Tutorial > [MySQLHelp]答朋友问:5000W记录的Innodb表如何快速的去重复数据_MySQL

[MySQLHelp]答朋友问:5000W记录的Innodb表如何快速的去重复数据_MySQL

WBOY
Release: 2016-06-01 13:18:56
Original
1436 people have browsed it

bitsCN.com

<strong>朋友问: </strong>
Copy after login
5000万数据的一张表,怎么去重快,根据两个字段判断是否重复。
Copy after login
<strong>回复之:</strong>
Copy after login
把2个字段以及主键id select 出来建立一张临时表t1,
Copy after login
t1建立好主键索引以及2个对比的字段联合索引。
Copy after login
然后在临时表里面 比对重复的记录,
Copy after login
把重复的记录录入第二张临时表t2,t2表结构和t1一模一样。
Copy after login
然后根据你的业务来决定如何处理t2表里面的重复记录,用t2关联原来的5000W记录的表来进行处理,
Copy after login
大概通常的是group by2个字段,取出主键id较大的值的记录删除掉。
Copy after login
bitsCN.com

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template