logo       

inet versus text for ip addresses: msg#00068

Subject: inet versus text for ip addresses
The PostgreSQL inet datatype stores an holds an IP host address, and 
optionally the identity of the subnet it is in, all in one field.  
This requires 12 bytes.   

Using my "random" data of approximately 8000 IP addresses collected 
during previous polls, I've found the average length of an IP address 
is 13.1 bytes.    An integer requires 4 bytes.

First question: Why not store an option to store just an IP address?  
That should require less than the 12 bytes for inet.

On to the real question:

The existing tables are:

create table recount_ips
(
    ipid        serial                not null,
    ipaddress   inet                  not null,
    primary key (ipid)
);

create unique index recount_ips_ip_address on recount_ips 
(ipaddress);

create table recount_iptopolls
(
    pollid      integer               not null,
    ipid        integer               not null,
    primary key (pollid, ipid)
);

alter table recount_iptopolls
    add foreign key  (pollid)
       references recount_polls (pollid) on update restrict on delete 
restrict;

alter table recount_iptopolls
    add foreign key  (ipid)
       references recount_ips (ipid) on update restrict on delete 
restrict;



I think a better solution is one table:

create table recount_iptopolls
(
    pollid      integer               not null,
    ipaddress   inet                  not null,
    primary key (pollid, ipaddress)
);

alter table recount_iptopolls
    add foreign key  (pollid)
       references recount_polls (pollid) on update restrict on delete 
restrict;

It removes a table and the associated primary key, and removed a 
foreign key from the modified recount_iptopolls table.

Comments?
-- 
Dan Langille : http://www.langille.org/


---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddressHere" to majordomo@xxxxxxxxxxxxxx)



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
web.pylons.gene...    hurd.l4/2002-10...    kernel.commits....    user-groups.lin...    yellowdog.gener...    java.drools.use...    security.openva...    package-managem...    linux.debian.us...    qnx.openqnx.dev...    genealogy.gramp...    file-systems.if...    voip.wengophone...    tex.context/200...    ietf.smime/2003...    audio.csound.de...    culture.region....    xfree86.devel/2...    mobile.kannel.u...    distributed.con...    education.engli...    org.user-groups...    bug-tracking.gn...    recreation.bicy...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe