请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

这一节内容,使用PPT 的语句 本地出来的结果不一样

老师问下,出来的结果不一样 mysql 8.0.11
CREATE TABLE inventory_3 (
inventory_id MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT,
film_id SMALLINT UNSIGNED NOT NULL,
store_id TINYINT UNSIGNED NOT NULL,
last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (inventory_id),
KEY idx_store_id_film_id (store_id,film_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

insert into inventory_3 select * from inventory;

  • explain select store_id from inventory_3 where store_id =1 and film_id = 3;

  •  		这个出来的结果的extra = Using index, 但是讲解的是 是Extra =Null
     	 -![图片描述](http://img1.sycdn.imooc.com//szimg/628222c2096ee8f807790086.jpg)
    
  • explain select store_id from inventory_3 where store_id in (1,2) and film_id = 3;
    - 这个出来的结果的extra = Using where; Using index, 但是讲解的是 是Extra = Using index condition
    图片描述

-这个using where 该怎么理解?

正在回答 回答被采纳积分+3

1回答

Moody 2022-05-17 09:29:00

1 有可能索引下推功能被关掉了,打开试一下:

SET optimizer_switch = 'index_condition_pushdown=on';

using where 就是回主表过滤的意思

0 回复 有任何疑惑可以回复我~
  • 提问者 慕设计1544558 #1
    sing where 就是回主表过滤 -》这时候就不算是走索引覆盖了对吧
    回复 有任何疑惑可以回复我~ 2022-05-17 17:35:24
  • 提问者 慕设计1544558 #2
    index_condition_pushdown = on 已经是打开的状态了
    回复 有任何疑惑可以回复我~ 2022-05-17 17:39:14
  • Moody 回复 提问者 慕设计1544558 #3
    show index 看下索引是不是对的吧
    
    SHOW INDEX FROM inventory_3\G;
    回复 有任何疑惑可以回复我~ 2022-05-17 18:08:03
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号