Quote:
Originally Posted by nickdodd25
I would think that the first one would be faster since inet_aton returns a integer. But something i just found out is you can add "explain" to the beginning of your query and it returns some helpful info.
pawn Код:
explain SELECT COUNT(ip) FROM some_table WHERE ip BETWEEN INET_ATON('45.166.0.0') AND INET_ATON('45.166.255.255'); //and explain SELECT COUNT(ip) FROM some_table WHERE INET_NTOA(ip) LIKE '45.166.%';
It will show how many rows were checked and it seems that the first one checked less rows so it should(might) be faster possibly. I could be wrong, its something i just found out lastnight.
|
Thanks for the "EXPLAIN" statement, I also took a look at "EXPLAIN EXTENDED" for
filtered.
Quote:
Originally Posted by Vince
Personally, I use the first one. But it must be noted that I select it from a humongous table which contains all CIDR ranges around the world, so the query usually looks something like:
PHP код:
SELECT country FROM iptable WHERE INET_ATON('x.x.x.x') BETWEEN range_start and range_end
There is no other way to do it because CIDR ranges could go from something like 25.47.0.0 to 25.48.255.255.
|
Alright, I'm going to use the first one as it was suggested by both of you - thank you for your replies.