我有两个表结构如下:(系统中每个对象类型的多个 ai_$object 表)
ai_$object , ai_ext_ids
-------------------- --------------------------
ext_id | hash id | ext_id | object_name | sfID
从批量删除中我得到了 sf_ids,并且需要从这两个表中删除记录,这种删除的最愚蠢的方式是这样的:
在伪代码中-->
$idToBeDeleted = SELECT ext_id FROM ai_tr_tbl_extids WHERE objectName='$object' AND sfID ='$s'" ;
DELETE FROM ai_tr_tbl_extids WHERE objectName='$object' AND sfID ='$s';
DELETE FROM ai_$object WHERE ext_id='$idToBeDeleted';
我的问题是如何提高这部分的性能?这段代码在循环中运行,我是否应该使用数组进行批量删除:SELECT * FROM table WHERE ID IN (1,2,3,4)