mysql> ALTER TABLE `cookies` ADD INDEX host_index (`host`);
Query OK, 0 rows affected (0.58 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> explain SELECT count(*) FROM cookies WHERE host='www.baidu.com';
+----+-------------+---------+------+---------------+------------+---------+-------+-------+--------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+---------+------+---------------+------------+---------+-------+-------+--------------------------+
| 1 | SIMPLE | cookies | ref | host_index | host_index | 302 | const | 48933 | Using where; Using index |
+----+-------------+---------+------+---------------+------------+---------+-------+-------+--------------------------+
1 row in set (0.00 sec)
ALTER TABLE `cookies` ADD INDEX status_index (`status`);
mysql> explain SELECT count(*) FROM cookies WHERE host='www.baidu.com' AND status=1;
+----+-------------+---------+------+-------------------------+--------------+---------+-------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+---------+------+-------------------------+--------------+---------+-------+------+-------------+
| 1 | SIMPLE | cookies | ref | host_index,status_index | status_index | 1 | const | 20 | Using where |
+----+-------------+---------+------+-------------------------+--------------+---------+-------+------+-------------+
1 row in set (0.01 sec)
mysql> explain SELECT count(*) FROM cookies WHERE status=1;
+----+-------------+---------+------+---------------+--------------+---------+-------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+---------+------+---------------+--------------+---------+-------+------+-------------+
| 1 | SIMPLE | cookies | ref | status_index | status_index | 1 | const | 20 | Using index |
+----+-------------+---------+------+---------------+--------------+---------+-------+------+-------------+
1 row in set (0.00 sec)