ip4r supports index lookups of the form (column >>= parameter), i.e. where you have a table of IP address ranges and wish to find which ones include a given IP address.
The PostgreSQL built-in types 'inet' and 'cidr' do not support index based lookups on ranges, as a result full table sequential scans are performed on many common Netdisco operations.
Use of this module should improve the database performance especially in large deployments.
This would require both installation of the module and modifications to the schema to use the new types and indices.
The module is available for Debian and Ubuntu: postgresql-9.x-ip4r however a quick scan did not indicate ip4r 2.x available as a RPM for CentOS / Redhat. 2.x needed for ipv4 and ipv6 support.
This may be something we consider as a fork or variant for large deployments that need the speed?
Results of limited testing with Subnet Utilization Report reduced run-time from approximately 10 minutes down to 20 seconds on a database with 500K+ IP's and 6K+ subnets using a 0.0.0.0/0 query.
Appears that RPM's for ip4r 2.01 are available at http://yum.postgresql.org
Other links I read whilst researching ip4r (nothing implied, I'm just bookmarking):
discussion about bringing ip4r into Pg core
range type mentioned in above link
range operators mentioned in above link
a post reporting the ip4r failing to build for Pg9.2
a post reporting successful port to Pg9.3?
Last edit: Oliver Gorwits 2014-02-25
Adding some additional links of interest for the discussion:
Why so few built-in range types?
GiST support for inet datatypes
The second is link is a current discussion (3/3/2014). These links give the impression that index support will be non-core, so require the installation of an extension and that you cannot simply use CREATE TYPE to define an inet / cidr range type.
As a fun exercise, I had a go at using the range types. I don't know whether it makes any difference. NB this is not fully v6 compat (but could be made so). I also ditched the date comparison just to force all records to be included.
Oh, and the reason for the numeric_value_out_of_range check is that the minus op for inet returns bigint so only works for two inets within 2^63 of each other(!).
Ticket moved from /p/netdisco/netdisco2/93/