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