Last published once deleted duplicate records of the article, where the best solution three deleted 1w also took 0.07 seconds and 2w has been spent 4 seconds. Further optimizations were made today, and it took only 1.06 seconds to test the removal of the 10w bar. The speed has improved a lot.
Build a Table statement
CREATE TABLE ' Test_user ' (
' ID ' INT (Ten) not NULL DEFAULT ' 0 ',
' Namea ' VARCHAR (+) not NULL,
' Nameb ' VARCHAR (+) not NULL,
' user_id ' VARCHAR (+) not NULL,
PRIMARY KEY (' id ')
) Engine=innodb DEFAULT Charset=utf8;
New scenario: (where user_id is a repeating field, keep one)
DELETE from Test_user WHERE ID not in (select-ID from (select MAX (ID) as-ID from Test_user GROUP by user_id) X);
10,000 Delete 9990 20,000 delete 19990 100,000 strip delete 199990
0.062sec 0.018sec 1.060sec
In addition, we summarize a method to delete Linux garbled files: (where the red part is the Inode (index node), the-I option is used to display the inode)
[[email protected] test]# ls
?????. Txt[[email protected] test]# Ls-lih
Total 4.0K
1061229-rw-r--r--. 1 root root 104 Jul 20:16?????. Txt
[[email protected] test]# find. -inum 1061229-exec rm {}-RF \;
[Email protected] test]# ls-l
Total 0
160802, 1.06s delete 10w duplicate record only keep one (MySQL) and Linux deleted garbled file