explain select im.item_id from item_message im FORCE INDEX (item_id) where ( im.keyStr like '%拉%' ) and im.class = 1 and im.top = 0 and industry = '餐饮' order by im.item_id desc LIMIT 0 , 8id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE im index NULL item_id 4 NULL 8 Using where 以上sql,可以再继续优化吗,不知为什么,type哪里总是标识index,是因为我排序的字段item_id是唯一的值有关吗?
另外再问一个菜鸟问题,如果我不用FORCE INDEX (item_id),explain结果如下id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE im ref Industry,class,top Industry 63 const 1 Using where; Using filesort
这是为什么呢?虽然有了 Using filesort,但这里的type却是ref,非常不明白,而我用了FORCE INDEX 会使我其他索引,如
keyStr 的FULLTEXT 失效吗附索引
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
item_message 0 PRIMARY 1 id A 8 NULL NULL BTREE
item_message 1 regional 1 regional A NULL NULL NULL YES BTREE
item_message 1 city 1 city A NULL NULL NULL BTREE
item_message 1 pic1 1 pic1 A NULL NULL NULL BTREE
item_message 1 pic2 1 pic2 A NULL NULL NULL BTREE
item_message 1 create_date 1 create_date A NULL NULL NULL BTREE
item_message 1 end_date 1 end_date A NULL NULL NULL BTREE
item_message 1 Industry 1 Industry A NULL NULL NULL YES BTREE
item_message 1 class 1 class A NULL NULL NULL BTREE
item_message 1 top 1 top A NULL NULL NULL BTREE
item_message 1 item_id 1 item_id A NULL NULL NULL BTREE
item_message 1 keyStr 1 keyStr NULL NULL NULL NULL YES FULLTEXT
1 SIMPLE im index NULL item_id 4 NULL 8 Using where 以上sql,可以再继续优化吗,不知为什么,type哪里总是标识index,是因为我排序的字段item_id是唯一的值有关吗?
另外再问一个菜鸟问题,如果我不用FORCE INDEX (item_id),explain结果如下id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE im ref Industry,class,top Industry 63 const 1 Using where; Using filesort
这是为什么呢?虽然有了 Using filesort,但这里的type却是ref,非常不明白,而我用了FORCE INDEX 会使我其他索引,如
keyStr 的FULLTEXT 失效吗附索引
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
item_message 0 PRIMARY 1 id A 8 NULL NULL BTREE
item_message 1 regional 1 regional A NULL NULL NULL YES BTREE
item_message 1 city 1 city A NULL NULL NULL BTREE
item_message 1 pic1 1 pic1 A NULL NULL NULL BTREE
item_message 1 pic2 1 pic2 A NULL NULL NULL BTREE
item_message 1 create_date 1 create_date A NULL NULL NULL BTREE
item_message 1 end_date 1 end_date A NULL NULL NULL BTREE
item_message 1 Industry 1 Industry A NULL NULL NULL YES BTREE
item_message 1 class 1 class A NULL NULL NULL BTREE
item_message 1 top 1 top A NULL NULL NULL BTREE
item_message 1 item_id 1 item_id A NULL NULL NULL BTREE
item_message 1 keyStr 1 keyStr NULL NULL NULL NULL YES FULLTEXT
7.2. 优化SELECT语句和其它查询
7.2.1. EXPLAIN语法(获取SELECT相关信息)
7.2.2. 估计查询性能
7.2.3. SELECT查询的速度
7.2.4. MySQL怎样优化WHERE子句
7.2.5. 范围优化
7.2.6. 索引合并优化
7.2.7. MySQL如何优化IS NULL
7.2.8. MySQL如何优化DISTINCT
7.2.9. MySQL如何优化LEFT JOIN和RIGHT JOIN
7.2.10. MySQL如何优化嵌套Join
7.2.11. MySQL如何简化外部联合
7.2.12. MySQL如何优化ORDER BY
7.2.13. MySQL如何优化GROUP BY
7.2.14. MySQL如何优化LIMIT
7.2.15. 如何避免表扫描
7.2.16. INSERT语句的速度
7.2.17. UPDATE语句的速度
7.2.18. DELETE语句的速度
7.2.19. 其它优化技巧