Skip site navigation (1) Skip section navigation (2)

Re: int4 vs varchar to store ip addr

From: Florian Weimer <fweimer(at)bfk(dot)de>
To: Pomarede Nicolas <npomarede(at)corp(dot)free(dot)fr>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: int4 vs varchar to store ip addr
Date: 2007-01-29 16:26:42
Message-ID: 82ac014x4t.fsf@mid.bfk.de (view raw or flat)
Thread:
Lists: pgsql-performance
* Pomarede Nicolas:

> I could use PG internal inet/cidr type to store the ip addrs, which
> would take 12 bytes per IP, thus gaining a few bytes per row.

I thought it's down to 8 bytes in PostgreSQL 8.2, but I could be
mistaken.

> Apart from gaining some bytes, would the btree index scan be faster
> with this data type compared to plain varchar ?

It will be faster because less I/O is involved.

For purposes like yours, there is a special ip4 type in a contributed
package which brings down the byte count to 4.  I'm not sure if it's
been ported to PostgreSQL 8.2 yet.

-- 
Florian Weimer                <fweimer(at)bfk(dot)de>
BFK edv-consulting GmbH       http://www.bfk.de/
Kriegsstra├če 100              tel: +49-721-96201-1
D-76133 Karlsruhe             fax: +49-721-96201-99

In response to

Responses

pgsql-performance by date

Next:From: Cosimo StrepponeDate: 2007-01-29 16:44:13
Subject: Re: int4 vs varchar to store ip addr
Previous:From: Pomarede NicolasDate: 2007-01-29 16:22:22
Subject: int4 vs varchar to store ip addr

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group