我有一个表,我主要更新,我想知道更新查询是否会受益于where列和更新列的索引或者列在哪一列?
I have a table which I do mainly updates and I'm wondering if update queries would benefit from having an index on the where column and the updated column or an index on just where column?
推荐答案就在where列上。更新列上的索引实际上会降低查询速度,因为索引必须与数据一起更新。 where列的索引将加速更新,并选择,但减慢一些插入。
Just on the where column. An index on the update column will actually slow down your query because the index has to be updated along with the data. An index on the where column will speed up updates, and selects, but slow down some insertions.
当删除行时,索引也会导致开销。一般情况下,对于你在 WHERE 上使用的列,它们是一件好事,并且它们对你加入的列基本上是必需的,或者 ORDER BY
Indices also cause overhead when you delete rows. In general they are a good thing though on columns you are using WHERE on a lot, and they are basically necessary on columns you do joins on, or ORDER BY
更多推荐
mysql更新查询是否从索引中受益?
发布评论