EXPLAIN SELECT COUNT(*) FROM t1 WHERE i1 =3 AND d ='2000-01-01'
执行计划取决于是否使用扩展索引。
当优化器不考虑索引扩展时,它将索引k_d视为(d)。 EXPLAIN对于查询产生以下结果:
mysql> EXPLAIN SELECT COUNT(*) FROM t1 WHERE i1 =3 AND d ='2000-01-01'\G***************************1. row*************************** id: 1 select_type: SIMPLEtable: t1type: refpossible_keys: PRIMARY,k_dkey: k_d key_len: 4 ref: constrows: 5 Extra: Using where; Using index
mysql> EXPLAIN SELECT COUNT(*) FROM t1 WHERE i1 =3 AND d ='2000-01-01'\G***************************1. row*************************** id: 1 select_type: SIMPLEtable: t1type: refpossible_keys: PRIMARY,k_dkey: k_d key_len: 8 ref: const,constrows: 1 Extra: Using index