List:General Discussion« Previous MessageNext Message »
From:SGreen Date:February 2 2006 4:34pm
Subject:Re: Fastest way to log IP's
View as plain text  
Brian Dunning <brian@stripped> 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

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