表存在对no字段的索引
当执行
explain select * from tName where no='ZKL'时,结果为id select_type table type posssible_keys key key_len ref rows Extra1 SIMPLE tName const tname001 tname001 10 1执行
explain select count(*) from tName where no='ZKL',结果为
id select_type table type posssible_keys key key_len ref rows Extra1 SIMPLE tName const tname001 tname001 10 1 Using index两个疑问
1、为何第一句执行时,extra反而没任何提示?
2、用coun(*)不是会全表扫描么,怎么反而有提示using index?
当执行
explain select * from tName where no='ZKL'时,结果为id select_type table type posssible_keys key key_len ref rows Extra1 SIMPLE tName const tname001 tname001 10 1执行
explain select count(*) from tName where no='ZKL',结果为
id select_type table type posssible_keys key key_len ref rows Extra1 SIMPLE tName const tname001 tname001 10 1 Using index两个疑问
1、为何第一句执行时,extra反而没任何提示?
2、用coun(*)不是会全表扫描么,怎么反而有提示using index?
这个COUNT(*), MYSQL只需要通过访问索引文件就可以了, 而SELECT * 还需要到数据文件中去取出相应的其它字段信息。