By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,695 Members | 1,317 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,695 IT Pros & Developers. It's quick & easy.

Efficient Storage of IP Address

P: n/a
Greetings,

I am establishing a database for the purpose of logging access to my secure
webserver and am wanting to make the database as efficient as I can because
it will be doing a lot of work when the site goes live.

What is the most efficient way in a MySQL table to store remote IP
addresses? What data type should I use? Should I just go with a basic
VARCHAR(15) to allow for 4 sets of 3 digits with 3 decimal separators, or is
there a better way?

Thanks,

Vance
Sep 15 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Vance M. Allen wrote:
I am establishing a database for the purpose of logging access to my
secure webserver and am wanting to make the database as efficient as I
can because it will be doing a lot of work when the site goes live.

What is the most efficient way in a MySQL table to store remote IP
addresses? What data type should I use? Should I just go with a
basic VARCHAR(15) to allow for 4 sets of 3 digits with 3 decimal
separators, or is there a better way?


http://dev.mysql.com/doc/mysql/en/mi...functions.html

Have a look at INET_ATON & INET_NTOA

--
Chris Hope | www.electrictoolbox.com | www.linuxcdmall.com
Sep 15 '05 #2

P: n/a
>I am establishing a database for the purpose of logging access to my secure
webserver and am wanting to make the database as efficient as I can because
it will be doing a lot of work when the site goes live.

What is the most efficient way in a MySQL table to store remote IP
addresses?
Define "efficient" for this application. Is "efficient" = "uses the least
disk space"? Or is "efficient" = "uses the least CPU time"?
What data type should I use? Should I just go with a basic
VARCHAR(15) to allow for 4 sets of 3 digits with 3 decimal separators, or is
there a better way?


You could use inet_ntoa() and inet_aton(). These save disk space.
They might possibly save disk i/o due to a smaller index or smaller
data. However, they use CPU time. How many times will you need to
convert these? Do you need to do subnet masking?

Gordon L. Burditt
Sep 15 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.