我正在花一些时间优化我们当前的数据库.
I am spending some time optimizing our current database.
我正在专门研究索引.
有几个问题:
索引会加速什么?
What will indexes speed up?
数据检索 -- SELECT 语句.
Data retrieval -- SELECT statements.
索引会减慢什么?
数据操作 -- INSERT、UPDATE、DELETE 语句.
Data manipulation -- INSERT, UPDATE, DELETE statements.
什么时候添加索引比较好?
When is it a good idea to add an index?
如果您想获得更好的数据检索性能.
If you feel you want to get better data retrieval performance.
什么时候添加索引是个坏主意?
When is it a bad idea to add an index?
在将要进行大量数据操作的表上 -- 插入、更新...
On tables that will see heavy data manipulation -- insertion, updating...
多索引与多列索引的优缺点?
Pro's and Con's of multiple indexes vs multi-column indexes?
在处理覆盖索引(多列上的索引)时,查询需要处理列的顺序,在索引列定义中从左到右.语句中的列顺序无关紧要,只有第 1、2 和 3 列的顺序 - 在使用索引之前,语句需要引用第 1 列.如果只有第 2 列或第 3 列的引用,则无法使用 1/2/3 的覆盖索引.
Queries need to address the order of columns when dealing with a covering index (an index on more than one column), from left to right in index column definition. The column order in the statement doesn't matter, only that of columns 1, 2 and 3 - a statement needs have a reference to column 1 before the index can be used. If there's only a reference to column 2 or 3, the covering index for 1/2/3 could not be used.
在 MySQL 中,查询中的每个 SELECT/语句只能使用一个索引(子查询/等被视为单独的语句).MySQL 允许的每个表的空间量是有限制的.此外,在索引列上运行函数会使索引无用 - IE:
In MySQL, only one index can be used per SELECT/statement in the query (subqueries/etc are seen as a separate statement). And there's a limit to the amount of space per table that MySQL allows. Additionally, running a function on an indexed column renders the index useless - IE:
WHERE DATE(datetime_column) = ...
这篇关于mysql 索引太多?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!