mysql> desc ip_isp;
+------------+------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+------------------+------+-----+---------+-------+
| ip_from | int(10) unsigned | NO | PRI | NULL | |
| ip_to | int(10) unsigned | NO | PRI | NULL | |
| cntry_code | char(2) | YES | | NULL | |
| cntry_name | varchar(64) | YES | | NULL | |
| isp_name | varchar(255) | YES | | NULL | |
+------------+------------------+------+-----+---------+-------+
5 rows in set (0.00 sec)
mysql> show index from ip_isp;
+--------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
+--------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| ip_isp | 0 | ip | 1 | ip_from | A | 3972496 | NULL | NULL | | BTREE | |
| ip_isp | 0 | ip | 2 | ip_to | A | 3972496 | NULL | NULL | | BTREE | |
+--------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
2 rows in set (0.00 sec)
mysql> explain select * from ip_isp where 1677721500 >= ip_from limit 1;
+----+-------------+--------+-------+---------------+------+---------+------+---------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+--------+-------+---------------+------+---------+------+---------+-------------+
| 1 | SIMPLE | ip_isp | range | ip | ip | 4 | NULL | 2199503 | Using where |
+----+-------------+--------+-------+---------------+------+---------+------+---------+-------------+
1 row in set (0.00 sec)
보시면 index(ip)를 이용하지 않는 듯합니다.
무엇이 문제일까요? |