From what I understand you want to optimize the script and obviously the performance.
It’s really not necessary to go all the way around.
See an example of DELETE with JOIN.
DELETE `items_rooms` FROM `items_rooms` AS T1 LEFT JOIN `catalog_items` AS T2
ON T2.item_ids = T1.base_item
WHERE T2.page_id='84'
I recommend that you back up before you run because I cannot guarantee the integrity of this by being unrelated to the structure of your system. But I believe it shouldn’t cause any trouble.
Nor do I guarantee that it will increase performance. It depends on the state of the structures, indexes, keys, etc.
There are other means of solving as by using multiple select. If this example above doesn’t change performance much, try to test other means, review how the data structure is, etc.
One remark, in older versions of Mysql, the use of the alias in DELETE expressions was not recognized. But I don’t remember at the time which version. Something close to 5.3 or 5.1.
Welcome to Stackoverflow-en. You can ask in English here Lucas, could edit your question and translate it?
– Renan Gomes
thanks for the information, you know how to help me? translated
– Lucas Abade
Probably not what you want... in a terminal run
php myscript
.– JJoao