The best way to improve the performance of 提高SELECT
operations is to create indexes on one or more of the columns that are tested in the query. SELECT
操作性能的最佳方法是在查询中测试的一个或多个列上创建索引。The index entries act like pointers to the table rows, allowing the query to quickly determine which rows match a condition in the 索引项的作用类似于指向表行的指针,允许查询快速确定哪些行与WHERE
clause, and retrieve the other column values for those rows. WHERE
子句中的条件匹配,并检索这些行的其他列值。All MySQL data types can be indexed.所有MySQL数据类型都可以被索引。
Although it can be tempting to create an indexes for every possible column used in a query, unnecessary indexes waste space and waste time for MySQL to determine which indexes to use. 尽管为查询中使用的每一个可能的列创建索引很有诱惑力,但不必要的索引浪费了MySQL确定要使用哪些索引的空间和时间。Indexes also add to the cost of inserts, updates, and deletes because each index must be updated. 索引还增加了插入、更新和删除的成本,因为每个索引都必须更新。You must find the right balance to achieve fast queries using the optimal set of indexes.您必须找到正确的平衡,才能使用最佳索引集实现快速查询。