Home > Backend Development > PHP Tutorial > MySQL怎么在select中用索引

MySQL怎么在select中用索引

WBOY
Release: 2016-06-13 13:36:53
Original
1030 people have browsed it

MySQL如何在select中用索引
给列(名为:column_a,素在表为:table_a)定义一个索引(名为:index_a);

我搜索列column_a时用一般方法

select column_a from table_a where 条件表达式;

那用上索引index_a应该怎样用呢?

------解决方案--------------------
没有理解索引,创建索引的目的为了大数据量时的查询性能, 

使用时,一般是where 后面带有 column_a 的查询条件可以了,就会比不创建索引进行搜索时快许多,在一定数据量时可以看出来
------解决方案--------------------
explain一下你的sql,在key字段可以看到是否使用了索引
------解决方案--------------------
看你的where条件是什么了 ,可以
explain select column_a from table_a where 条件表达式;
看是否使用了索引。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template