160802, 1.06s delete 10w duplicate record only keep one (MySQL) and Linux deleted garbled file

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.