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:
And in PHP, you also have the ip2long() and long2ip()
(just be aware of signed/unsigned integers)
> -----Original Message-----
> From: Brian Dunning [mailto:brian@stripped]
> Sent: Thursday, February 02, 2006 8:21 AM
> To: mysql@stripped
> 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: