Received: from localhost (unknown [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 0D1A09FC9BA for ; Thu, 25 Oct 2007 16:32:22 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 56673-08 for ; Thu, 25 Oct 2007 16:32:18 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 2A09D9FC9E6 for ; Thu, 25 Oct 2007 16:32:17 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.1/8.14.1) with ESMTP id l9PJWF6Y023758; Thu, 25 Oct 2007 15:32:15 -0400 (EDT) To: "Jamie Tufnell" cc: pgsql-sql@postgresql.org Subject: Re: JOINing based on whether an IP address is contained within a CIDR range? In-reply-to: References: Comments: In-reply-to "Jamie Tufnell" message dated "Thu, 25 Oct 2007 19:22:41 +0100" Date: Thu, 25 Oct 2007 15:32:15 -0400 Message-ID: <23757.1193340735@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200710/125 X-Sequence-Number: 29497 "Jamie Tufnell" 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