MySQL索引及Profiling小知识
总结一下一些常用的MySQL索引及Profiling小知识,
一,查看某个表的索引
- mysql > show indexes from [tablename] \G
- Table: album
- Non_unique: 0
- Key_name: PRIMARY
- Seq_in_index: 1
- Column_name: album_id
- Collation: A
- Cardinality: 29
- Sub_part: NULL
- Packed: NULL
- Null:
- Index_type: BTREE
- Comment:
二,强制索引
- mysql > select * from [tablename] force index([indexname]) where [xxxx]
三,创建索引
- mysql > create index [index_name] on [tablename] ([index]);
四,删除索引
- mysql > drop index [index_name] on [tablename];
索引的好坏直接影响到MySQL数据库的执行性能,可结合Explain和Profiling工具进行检查。
Profiling使用方法如下:
- mysql > set profiling = 1;
- mysql > select * from [tablename]
- mysql > show profiles;
- mysql > show profile [cpu, block] io for query [xx];
掌握profiling检查MySQL的执行情况。
原创文章如转载,请注明:转载自 必优博客 http://www.biuuu.com/
本文链接地址:http://www.biuuu.com/p1284.html
Tags:mysql profiling mysql索引
作者:biuuu | 分类:MySQL | 评论:0 | 引用:0 | 浏览:2597































我要评论