I want to execute a MySQL query in order to delete all Wp_posts
table rows which post_parent
is a Wp_posts
row with post_type
set to product;
So I do
INSERT INTO temp (SELECT DISTINCT id FROM wp_posts WHERE post_type = "product")
(Inserts 4k rows)
DELETE FROM wp_posts WHERE post_parent IN (SELECT tid FROM temp)
..
After around 100 seconds, it returns
ERROR 1317 (70100): Query execution was interrupted
What could be making this query so bloody slow?
You need change your
max_allowed_packet
to a higher value in yourmy.ini
configuration file.This might help:
Some versions of MySQL implement
in
with a subquery in a very inefficient manner. Change it to a correlatedexists
clause: