本文介绍了从mysql删除数据的最快方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在这样做:

delete from calibration_2009 where rowid in
(SELECT rowid FROM `qcvalues`.`batchinfo_2009` where reporttime like "%2010%");

我需要删除大约 25 万行.

i need to have about 250k rows deleted.

为什么需要这么长时间?有没有更快的方法来做到这一点?

why does it take such a long time? is there a quicker way to do this?

推荐答案

DELETE  c
FROM    `qcvalues`.`batchinfo_2009` b
JOIN    calibration_2009 c
ON      c.rowid = b.rowid
WHERE   b.reporttime LIKE '%2010%';

您应该在 calibration_2009 (rowid) 上有一个索引,以便快速工作.

You should have an index on calibration_2009 (rowid) for this to work fast.

我认为它是一个 PRIMARY KEY 无论如何,但你最好检查一下.

I assume it's a PRIMARY KEY anyway, but you better check.

这篇关于从mysql删除数据的最快方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 18:10