Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id A7A8A9FA4DF for ; Tue, 30 Jan 2007 06:54:09 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-new, port 10024) with ESMTP id 45081-05 for ; Tue, 30 Jan 2007 06:54:06 -0400 (AST) X-Greylist: whitelisted by SQLgrey-1.7.4 Received: from smtp2-g19.free.fr (smtp2-g19.free.fr [212.27.42.28]) by postgresql.org (Postfix) with ESMTP id 946339F9428 for ; Tue, 30 Jan 2007 06:54:06 -0400 (AST) Received: from pulsar.staff.proxad.net (pulsar.staff.proxad.net [213.228.1.109]) by smtp2-g19.free.fr (Postfix) with ESMTP id 72BED7D1F; Tue, 30 Jan 2007 11:54:05 +0100 (CET) Date: Tue, 30 Jan 2007 11:54:05 +0100 (CET) From: Pomarede Nicolas X-X-Sender: npomarede@localhost To: Florian Weimer cc: pgsql-performance@postgresql.org Subject: Re: int4 vs varchar to store ip addr In-Reply-To: <82ac014x4t.fsf@mid.bfk.de> Message-ID: References: <82ac014x4t.fsf@mid.bfk.de> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200701/420 X-Sequence-Number: 23021 On Mon, 29 Jan 2007, Florian Weimer wrote: > * 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. Yes thanks for this reference, ip4r package seems to be a nice addition to postgres for what I'd like to do. Does someone here have some real life experience with it (regarding performance and stability) ? Also, is it possible that this package functionalities' might be merged into postgres one day, I think the benefit of using 4 bytes to store an ipv4 addr could be really interesting for some case ? thanks, ---------------- Nicolas Pomarede e-mail: npomarede@corp.free.fr "In a world without walls and fences, who needs windows and gates ?"