MySQL Forums
Forum List  »  Performance

Re: Slow query
Posted by: Rick James
Date: February 15, 2011 11:17AM

OK, not surprise in the EXPLAIN EXTENDED:
select `transfer_ro_pre`.`location`.`locId` AS `locId`,
       `transfer_ro_pre`.`location`.`city` AS `city`,
       `transfer_ro_pre`.`location`.`latitude` AS `latitude`,
       `transfer_ro_pre`.`location`.`longitude` AS `longitude`
    from  `transfer_ro_pre`.`ip2isp`
    join  `transfer_ro_pre`.`location`
    where  ((inet_aton('x.x.x.x') between
                           `transfer_ro_pre`.`ip2isp`.`start`
                      and  `transfer_ro_pre`.`ip2isp`.`end`)
      and  (`transfer_ro_pre`.`ip2isp`.`location` = `transfer_ro_pre`.`location`.`locId`)) |

Unfortunately, the type of query is hard to optimize.

Raising key_buffer_size may be the only significant improvement available.

This may help some, but minimizing the bulk of the temp table:
SELECT L.locId, L.city, L.latitude, L.longitude
    FROM  location AS L
    JOIN (
        SELECT location
            FROM ip2isp
            WHERE  INET_ATON('x.x.x.x') BETWEEN start AND end
         ) AS I  ON I.location = L.locId
To make that more efficient, change
KEY `isp2idx` (`start`,`end`),
to
KEY `isp2idx` (`start`,`end`, location),
(Then it can do the subquery entirely in the INDEX.)

Options: ReplyQuote


Subject
Views
Written By
Posted
3013
February 11, 2011 08:55AM
981
February 12, 2011 03:32PM
1148
February 14, 2011 07:55AM
941
February 14, 2011 08:12AM
823
February 14, 2011 09:59AM
714
February 14, 2011 10:57AM
745
February 14, 2011 06:51PM
955
February 15, 2011 03:21AM
Re: Slow query
1135
February 15, 2011 11:17AM


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.