MySQL Forums
Forum List  »  Newbie

Re: Full Table Scan With Simple SELECT
Posted by: Shawn Hogan
Date: April 09, 2005 10:25AM

I ended up changing the query from this:

SELECT * FROM geoip WHERE ipFROM <= $ip_long AND ipTO >= $ip_long

to this:

SELECT * FROM geoip WHERE ipFROM <= $ip_long ORDER BY ipFROM DESC LIMIT 1

...and it was able to effectively utilize the index (and sped everything up).

But it seems like a very inefficient hack to me. Potentially getting as many as 1.6M records, then sorting them to make sure you get the first one.

I guess MySQL just can't effectively use indexes on ranged queries on multiple columns?

Options: ReplyQuote


Subject
Written By
Posted
Re: Full Table Scan With Simple SELECT
April 09, 2005 10:25AM


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.