> use mgnt;
> create index 索引名 on clusters_cluster(cluster_name); # create创建索引。
> alter table table_name add index 索引名(cluster_name) ; # alter方法创建索引, table_name表名,cluster_name字段名。
索引分类:
PRIMARY, INDEX, UNIQUE 这3种是一类
PRIMARY 主键。 就是 唯一 且 不能为空。
INDEX 索引,普通的 , 如:create index index_name on clusters_cluster(cluster_name);
UNIQUE 唯一索引。 不允许有重复。
FULLTEXT 是全文索引,用于在一篇文章中,检索文本信息的。
案例:1. 非索引查询 select * from monitors_mondiskio order by time desc limit 20; 共6.95秒 7166398条数据。
2. 主键索引查询 select * from monitors_mondiskio order by rec_id desc limit 20; 0.00 秒 7173027条数据。
3. 可以把time 非空字段,添加索引。便于快速查询。
因篇幅问题不能全部显示,请点此查看更多更全内容