索引 idx_fk_customer_id 长短独一索引,萌芽前提为等值萌芽前提 customer_id = 350, 所以扫描索引的类型为 ref。ref 还经常涌如今 join 操作中:
- mysql> explain select b.*, a.* from payment a,customer b where a.customer_id = b.customer_id \G
- *************************** 1. row ***************************
- id: 1
- select_type: SIMPLE
- table: b
- partitions: NULL
- type: ALL
- possible_keys: PRIMARY
- key: NULL
- key_len: NULL
- ref: NULL
- rows: 599
- filtered: 100.00
- Extra: NULL
- *************************** 2. row ***************************
- id: 1
- select_type: SIMPLE
- table: a
- partitions: NULL
- type: ref
- possible_keys: idx_fk_customer_id
- key: idx_fk_customer_id
- key_len: 2
- ref: sakila.b.customer_id
- rows: 26
- filtered: 100.00
- Extra: NULL
- 2 rows in set, 1 warning (0.00 sec)
对于事务型的应用,经由过程 Com_commit 和 Com_rollback 可以懂得事务提交和回滚的情况,对于回滚操作异常频繁的数据库,可能意味着应用编写存在问题。
5. type=eq_ref,类似 ref,差别就在应用的索引时独一索引,对于每个索引的键值,表中只要一笔记录匹配;简单的说,就是多表连接中应用 primary key 或者 unique index 作为接洽关系前提。
- mysql> explain select * from film a , film_text b
推荐阅读
远胜微软谷歌等翻译器 | 基于神经网络和超级计算机的DeepL Translator
Microsoft Translator是微软旗下的翻译对象,痊愈客岁成功切换至神经网路。当时,微软表示比拟较今朝行业内主流的统计机械翻译(SMT)技巧,神经收集架构可以或许大年夜幅晋升翻译质量。德>>>详细阅读
本文标题:优化SQL语句的一般步骤
地址:http://www.17bianji.com/lsqh/37055.html
1/2 1

网友点评
精彩导读
科技快报
品牌展示