Answer the question
In order to leave comments, you need to log in
MySQL magic, or why does DELETE take forever?
There is a table with 100000 records. The table looks like this:
increment | data [text] | dataId[varchar45] | userId[int11] |
---|
DELETE
FROM userdata
WHERE dataId in (
SELECT concat('ufi',dbIncrement)
FROM ufields
WHERE podvedId='val'
and formId='val'
and parentContainerId='val'
and (descriptor_x='val' or descriptor_y='val')
)
// очень долго выполняется, сервер падает
Answer the question
In order to leave comments, you need to log in
DELETE `ud`.*
FROM `userdata` AS `ud`
JOIN `ufields` AS `uf`
ON `ud`.`dataId` = CONCAT('ufi', `uf`.`dbIncrement`)
AND `uf`.`podvedId` = 'val'
AND `uf`.`formId` = 'val'
AND `uf`.`parentContainerId` = 'val'
AND (`uf`.`descriptor_y` = 'val' OR `uf`.`descriptor_y` = 'val')
Push result in the temporary table and make selection from it. Where it will no longer be necessary to perform concat.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question