01.11.2014, 16:09
Quote:
This is also very true. Are you using a naive linear search or something like a binary search?
|
Quote:
3) Filling the database with all the ips manually would have taken a significative amount of time. I can't clearly tell you how much since I haven't ever tried something of this kind, but I think you can guess.
|
Quote:
Well, the list is really big (at least, I consider it as very big, +- 10'000 ips), and the time eleapsed from the moment I saw the first loading sentence ("Loading filterscript...") to the moment I saw the second one ("Filterscript loaded !"), I really felt the second eleapsed.
|
- Set an index in your table.
- Use an integer instead of a string for an IP address (Check INET_ATON() and INET_NTOA() here: http://dev.mysql.com/doc/refman/5.0/...functions.html).
Code:
mysql> SELECT * FROM `ip_table`; +-------------+ | ip | +-------------+ | -2145172593 | | -2143952536 | | -2143817842 | | -2142775430 | | -2141970877 | | -2141543934 | | -2141495142 | | -2140798626 | | -2140726879 | | ... | | -2140185323 | | -2140124424 | | 2145686361 | | 2146865570 | | 2147010485 | | 2147290286 | +-------------+ 10000 rows in set (0.00 sec) mysql> SELECT NULL FROM `ip_table` WHERE `ip` = -1819749934; Empty set (0.00 sec) mysql> SELECT NULL FROM `ip_table` WHERE `ip` = 2145686361; +------+ | NULL | +------+ | NULL | +------+ 1 row in set (0.00 sec)