I work at a security company, and we store many thousands of IPs in mySQL
for networks as large as /16. 

Use INTEGERS. It's much more efficient. It's easier to use. And it allows
your sorting (ORDER BY) to be in the proper order. 

If you stored as characters you'd eroneously get:

192.168.1.1
192.168.1.10
192.168.1.2
192.168.1.3
192.168.1.4
192.168.1.5
192.168.1.6
192.168.1.7
192.168.1.8
192.168.1.9
...

And in PHP, you also have the ip2long() and long2ip()

(just be aware of signed/unsigned integers)


> -----Original Message-----
> From: Brian Dunning [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, February 02, 2006 8:21 AM
> To: mysql@lists.mysql.com
> Subject: Fastest way to log IP's
> 
> I'm logging IP addresses and also searching for existing ones. Does  
> anyone happen to know which is more resource intensive: storing the  
> IP's as integers using INET_NTOA() and INET_ATON() to convert 
> them at  
> each query; or simply storing the IP as a varchar? In each case the  
> IP field would be the primary key.
> 
> -- 
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    
> http://lists.mysql.com/[EMAIL PROTECTED]
> 
> 


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to