List:General Discussion« Previous MessageNext Message »
From:wroxdb Date:November 9 2010 9:18am
Subject:Re: a query not using index
View as plain text  
在 2010年11月9日 下午3:51,Johan De Meersman <vegivamp@stripped> 写道:
> Indexes  typically only work on the left-hand-side. Rewrite as
> select * from ip_test where startNum <= 3061579775 and endNum >= 3061579775;
>

Thanks.

But this seems the same case happened:

mysql> desc select * from ip_test where startNum <= 3061579775 and
endNum >= 3061579775;
+----+-------------+---------+------+-----------------+------+---------+------+--------+-------------+
| id | select_type | table   | type | possible_keys   | key  | key_len
| ref  | rows   | Extra       |
+----+-------------+---------+------+-----------------+------+---------+------+--------+-------------+
|  1 | SIMPLE      | ip_test | ALL  | startNum,endNum | NULL | NULL
| NULL | 396528 | Using where |
+----+-------------+---------+------+-----------------+------+---------+------+--------+-------------+


And I'm sure the select can fetch records:

mysql> select * from ip_test where startNum <= 3061579775 and endNum
>= 3061579775;
+------------+------------+---------+----------+------+--------+
| startNum   | endNum     | country | province | city | isp    |
+------------+------------+---------+----------+------+--------+
| 3061514240 | 3061579775 | 中国    | 河南     |      | 联通   |


Please suggest, thanks again.

Regards.
Thread
a query not using indexwroxdb9 Nov
  • Re: a query not using indexJohan De Meersman9 Nov
    • Re: a query not using indexwroxdb9 Nov
    • Re: a query not using indexAveek Misra9 Nov
      • Re: a query not using indexwroxdb9 Nov
        • Re: a query not using indexAveek Misra9 Nov
          • Re: a query not using indexJohnny Withers9 Nov
  • Re: a query not using indexMySQL)9 Nov