Re: Efficiently searching for CIDRs containing an IP address - Mailing list pgsql-admin

From Alan McKay
Subject Re: Efficiently searching for CIDRs containing an IP address
Date
Msg-id 844129e80905311814o4ab50ad8jb41172010ce612b4@mail.gmail.com
Whole thread Raw
In response to Re: Efficiently searching for CIDRs containing an IP address  ("David F. Skoll" <dfs@roaringpenguin.com>)
Responses Re: Efficiently searching for CIDRs containing an IP address  ("David F. Skoll" <dfs@roaringpenguin.com>)
List pgsql-admin
Hmmm, I've never done this quite that way, but IPs - especially CIDRs
- are far easier to work with in binary format than in human-readable
format.  At my old workplace about 5 years ago I wrote an IP
management system (PHP/MySQL) that stored the IP in binary and
human-readable formats, but all of the computations and comparisons
and other such stuff always took place with the binary values (binary
stored as a string of 0s and 1s as I recall).

So is this not simply easier to implement with a library of functions
to convert a string to binary and back?  I recall in my implementation
I had only 4 or 5 functions including converting back-and-forth from
binary to human-readable, binary-AND, binary-OR and maybe one or two
others.


--
“Mother Nature doesn’t do bailouts.”
         - Glenn Prickett

pgsql-admin by date:

Previous
From: Tom Lane
Date:
Subject: Re: PostgreSQL crashes
Next
From: "David F. Skoll"
Date:
Subject: Re: Efficiently searching for CIDRs containing an IP address