用 mysql explain 命令查看查询性能

explain用法: explain + 查询语句 如:
explain select * from `sns_hits` where resource_id = 13 and resource_type = 'THREAD'


查询结果主要有 7列
1 table:使用的表明
2 type:关联类型,对于单表有4个重要值:const range index all
  const -- 主键索引
  range -- 范围索引
  index -- 扫描索引树
  all   -- 全表扫描
3 possible_key : 查询可能使用的索引
4 key : 实际使用的索引
5 key_len : 索引使用了多少字节
6 ref: 那些字段作为常量引用被使用
7 rows : mysql需要查看多少行才能找到结果集 这是个重要参数

你可能感兴趣的:(thread,mysql,SNS)