I have a delete query who work well with small amount of row. But now with about 80K row it's failling due to "timeout"
My two table are like that :
TableA
------
| Column | type |
|------------|------------|
| link_id | bigint(40) |
| product_id | int(10) |
| parent_id | int(10) |
Table B
-------
| Column | type |
|-----------|---------|
| id | int(11) |
| parent_id | int(11) |
| child_id | int(11) |
I do a query like that to make a delete
DELETE FROM TABLEA
WHERE link_id IN (
SELECT link_id FROM (
SELECT link_id, parent_id, product_id FROM TABLEA
UNION ALL
SELECT id, parent_id, child_id FROM TABLEB
) tbl
GROUP BY parent_id, product_id
HAVING count(*) = 1
ORDER BY parent_id
) ;
But whould not be the most optimized one.
The goal is to delete from table A all records not present in table B for the couple "parent_id / child_id".
in Table A the column "product_id" is the "child_id".
Thanks