MySQL multiple table Delete hurry up and hurry up. What to do with it

Source: Internet
Author: User
MySQL multiple table Delete hurry up and hurry up ....
Table A B C D E F G

PHP Code
  
  a.ID = B.aid = C.aid = D.aid = E.aid = F.aid = G.aid


Now we're going to delete all the data in the table with ID 1.

I just started to write the loop delete but the execution is too slow

There is no better way to make it more efficient

------Solution--------------------
Delete from A where id=1;
Delete from B where aid=1;
.........................
------Solution--------------------
Explore

Reference:

Delete from A where id=1;
Delete from B where aid=1;
.........................


I wrote that too. Loop Array (a,b,c,d,e,...); Then the deletion may be due to too much data in the table (about 1.3 million or so)
Deleting a piece takes about 3 4 seconds

------Solution--------------------
Index on aid for all tables
Operate on a per-loop basis

If all are InnoDB type table
Then the foreign key of a.ID is built on the aid of a table other than a
Only delete from A where id=1 can
  • 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.