我发现以下查询导致了一些瓶颈(执行时间超过 40 秒!)
DELETE FROM doctors
WHERE (SELECT COUNT(loc_id)
FROM locations
WHERE locations.loc_doctor = doctors.doc_id) = 0 AND
doctors.doc_user = $myVar
我想问题出在该(SELECT COUNT(loc_id) FROM locations WHERE locations.loc_doctor = doctors.doc_id) = 0
部分,对吗?有没有办法改进它?