Brian Dunning <[EMAIL PROTECTED]> wrote on 02/02/2006 11:21:25 AM:

> 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.
> 

You will get much faster searches if you convert to integers first. Your 
indexes will be smaller (more likely to sit and stay in memory), each term 
will be numerically compared( 5-50 times faster than string comparisons on 
average), and your data footprint will be smaller (more likely to stay in 
the file cache of the OS or the query cache of the server). The conversion 
routines INET_NTOA() and INET_ATON() are small and tight so you should not 
hit too much overhead by calling them whenever you need them.

My advice? Stick with the numeric form of the address.

Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine

Reply via email to