Re: [GENERAL] appropriate column for storing ipv4 address - Mailing list pgsql-general

From Steve Atkins
Subject Re: [GENERAL] appropriate column for storing ipv4 address
Date
Msg-id ABDAA428-A7AE-4E99-ABD5-16B1407B8DA4@blighty.com
Whole thread Raw
In response to [GENERAL] appropriate column for storing ipv4 address  (jonathan vanasco <postgres@2xlp.com>)
List pgsql-general
> On Mar 1, 2017, at 8:39 AM, jonathan vanasco <postgres@2xlp.com> wrote:
>
>
> I have to store/search some IP data in Postgres 9.6 and am second-guessing my storage options.
>
>
> The types of searching I'm doing:

[...]

>
>     2. on tracked_ip_block, i search/join against the tracked_ip_address to show known ips in a block, or a known
blockfor an ip. 
>
> i used cidr instead of inet for the ip_address because it saved me a cast on joins and appears to work the same.  was
thatthe right move?  is there a better option? 

If you're looking to do fast searches for "is this IP address in any of these CIDR blocks" you might want to look at
https://github.com/RhodiumToad/ip4ras a possible alternative. 

Cheers,
  Steve

pgsql-general by date:

Previous
From: Paul Jungwirth
Date:
Subject: Re: [GENERAL] appropriate column for storing ipv4 address
Next
From: jonathan vanasco
Date:
Subject: Re: [GENERAL] disk writes within a transaction