mysql> explain select * from test where name = 1 and age = 1; +----+-------------+-------+------+---------------+------+---------+------+--------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+------+---------------+------+---------+------+--------+-------------+ | 1 | SIMPLE | test | ALL | union_x | NULL | NULL | NULL | 997182 | Using where | +----+-------------+-------+------+---------------+------+---------+------+--------+-------------+
mysql> explain select * from test where age = 1 and name = 1; +----+-------------+-------+------+---------------+------+---------+------+--------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+------+---------------+------+---------+------+--------+-------------+ | 1 | SIMPLE | test | ALL | union_x | NULL | NULL | NULL | 997182 | Using where | +----+-------------+-------+------+---------------+------+---------+------+--------+-------------+
mysql> explain select * from test where name = 1; +----+-------------+-------+------+---------------+------+---------+------+--------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+------+---------------+------+---------+------+--------+-------------+ | 1 | SIMPLE | test | ALL | union_x | NULL | NULL | NULL | 997182 | Using where | +----+-------------+-------+------+---------------+------+---------+------+--------+-------------+
mysql> explain select * from test where age = 1; +----+-------------+-------+------+---------------+------+---------+------+--------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+------+---------------+------+---------+------+--------+-------------+ | 1 | SIMPLE | test | ALL | NULL | NULL | NULL | NULL | 997182 | Using where | +----+-------------+-------+------+---------------+------+---------+------+--------+-------------+
mysql> explain select name,age from test where age = 1; +----+-------------+-------+-------+---------------+---------+---------+------+--------+--------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+-------+---------------+---------+---------+------+--------+--------------------------+ | 1 | SIMPLE | test | index | NULL | union_x | 38 | NULL | 997182 | Using where; Using index | +----+-------------+-------+-------+---------------+---------+---------+------+--------+--------------------------+