mysql更新查询是否从索引中受益?

编程入门 行业动态 更新时间:2024-10-21 17:43:04
本文介绍了mysql更新查询是否从索引中受益?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个表,我主要更新,我想知道更新查询是否会受益于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更新查询是否从索引中受益?

本文发布于:2023-11-09 05:49:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1571545.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:索引   mysql

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!