MySQL Forums
Forum List  »  Performance

Re: Keys ignored for larger tables!?
Posted by: tamas marki
Date: April 07, 2011 05:59AM

mysql> explain 
    -> select start.id 
    ->   from ( select id from arinrange where ip_start<=1582783255 ) start
    ->   join ( select id from arinrange where ip_end>=1582783255 ) end
    ->     on start.id = end.id;
+----+-------------+------------+-------+------------------+------------------+---------+------+---------+--------------------------+
| id | select_type | table      | type  | possible_keys    | key              | key_len | ref  | rows    | Extra                    |
+----+-------------+------------+-------+------------------+------------------+---------+------+---------+--------------------------+
|  1 | PRIMARY     | <derived3> | ALL   | NULL             | NULL             | NULL    | NULL |  674023 |                          | 
|  1 | PRIMARY     | <derived2> | ALL   | NULL             | NULL             | NULL    | NULL | 1316679 | Using where              | 
|  3 | DERIVED     | arinrange  | range | idx_end_start_id | idx_end_start_id | 4       | NULL |  727188 | Using where; Using index | 
|  2 | DERIVED     | arinrange  | range | idx_start_end_id | idx_start_end_id | 4       | NULL | 1263515 | Using where; Using index | 
+----+-------------+------------+-------+------------------+------------------+---------+------+---------+--------------------------+
4 rows in set (1.87 sec)

mysql> 
mysql> explain select id from arinrange where 1582783255 between ip_start and ip_end ;
+----+-------------+-----------+-------+-----------------------------------+------------------+---------+------+--------+--------------------------+
| id | select_type | table     | type  | possible_keys                     | key              | key_len | ref  | rows   | Extra                    |
+----+-------------+-----------+-------+-----------------------------------+------------------+---------+------+--------+--------------------------+
|  1 | SIMPLE      | arinrange | range | idx_start_end_id,idx_end_start_id | idx_end_start_id | 4       | NULL | 727188 | Using where; Using index | 
+----+-------------+-----------+-------+-----------------------------------+------------------+---------+------+--------+--------------------------+
1 row in set (0.00 sec)

Options: ReplyQuote


Subject
Views
Written By
Posted
2535
April 06, 2011 04:00AM
Re: Keys ignored for larger tables!?
871
April 07, 2011 05:59AM
1600
April 08, 2011 08:20PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.