List:General Discussion« Previous MessageNext Message »
From:Daevid Vincent Date:February 7 2006 8:26pm
Subject:RE: Fastest way to log IP's
View as plain text  
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:
> To unsubscribe:    

Fastest way to log IP'sBrian Dunning2 Feb
  • Re: Fastest way to log IP'sSGreen2 Feb
  • Re: Fastest way to log IP'sAsad Habib2 Feb
  • Re: Fastest way to log IP'sJay Paulson2 Feb
  • RE: Fastest way to log IP'sDaevid Vincent7 Feb