Re: Efficiently searching for CIDRs containing an IP address

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "David F(dot) Skoll" <dfs(at)roaringpenguin(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Efficiently searching for CIDRs containing an IP address
Date: 2009-05-29 15:35:43
Message-ID: 18260.1243611343@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

"David F. Skoll" <dfs(at)roaringpenguin(dot)com> writes:
> I want to efficiently support queries like this:
> SELECT * FROM networks WHERE '128.3.4.5' <<= iprange;
> There doesn't seem to be any indexing mechanism in core PostgresSQL that
> supports this; it always does a sequential scan.

Yeah. Something that's been on the TODO list for a long time is to put
together a GIST index opclass that handles this sort of thing. I have
not looked at ip4r in detail, but it seems like whatever that's doing
for index support could be transposed to the built-in types. Or you
could base it on the contrib/seg indexing code (but beware that we've
recently found serious performance bugs in the latter).

regards, tom lane

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message David F. Skoll 2009-05-29 20:44:25 Re: Efficiently searching for CIDRs containing an IP address
Previous Message David F. Skoll 2009-05-29 14:33:45 Efficiently searching for CIDRs containing an IP address