pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jamie Tufnell <diesql@googlemail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: JOINing based on whether an IP address is contained within a CIDR range?
Date: Thu, 25 Oct 2007 15:32:15 -0400
Message-ID: <23757.1193340735@sss.pgh.pa.us> (raw)
In-Reply-To: <b0a4f3350710251122y10648d4id322f12a81001c07@mail.gmail.com>
References: <b0a4f3350710251122y10648d4id322f12a81001c07@mail.gmail.com>

"Jamie Tufnell" <diesql@googlemail.com> writes:
> Is it possible to somehow JOIN using the <<= and
> = network operators?

Sure, why not?

You probably won't get a plan that's smarter than a nestloop, but I
imagine you'll have few enough rows in network_names that it won't
matter.

One potential problem is if there could be overlapping entries in
network_names --- the join would give you multiple rows for any
log entry that matches more than one network_names entry.  You
could fix that using a subselect with LIMIT 1, as long as you
weren't too picky about which name got reported.

			regards, tom lane



view thread (5+ messages)  latest in thread

Message-ID: <23757.1193340735@sss.pgh.pa.us>
Permalink:  ../23757.1193340735@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/23757.1193340735@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, diesql@googlemail.com
  Subject: Re: JOINing based on whether an IP address is contained within a CIDR range?
  In-Reply-To: <23757.1193340735@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox