Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 996279FB204 for ; Thu, 1 Feb 2007 14:25:29 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-new, port 10024) with ESMTP id 61924-05 for ; Thu, 1 Feb 2007 14:25:19 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id D80359FB1DC for ; Thu, 1 Feb 2007 14:25:20 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from home.wiles.org (frank.wiles.org [24.124.39.75]) by svr4.postgresql.org (Postfix) with ESMTP id 79AFC5AF9AF for ; Thu, 1 Feb 2007 18:25:20 +0000 (GMT) Received: from localhost.localdomain (frank.wiles.org [24.124.39.75]) by home.wiles.org (8.13.8/8.13.8) with SMTP id l11IPHgx027993; Thu, 1 Feb 2007 12:25:17 -0600 Date: Thu, 1 Feb 2007 12:20:45 -0600 From: Frank Wiles To: "Michael Artz" Cc: pgsql-performance@postgresql.org Subject: Re: Subselect query enhancement Message-Id: <20070201122045.79ff29c8.frank@wiles.org> In-Reply-To: References: X-Mailer: Sylpheed version 2.2.10 (GTK+ 2.8.20; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200702/6 X-Sequence-Number: 23060 On Thu, 1 Feb 2007 11:42:03 -0500 "Michael Artz" wrote: > I'm needing help determining the best all-around query for the > following situation. I have primary table that holds ip information > and two other tables that hold event data for the specific IP in with > a one-to-many mapping between them, ie: > > CREATE TABLE ip_info ( > ip IP4, > --other data > ); > > CREATE TABLE network_events ( > ip IP4 NOT NULL REFERENCES ip_info(ip), > name VARCHAR, > port INTEGER, > --other data > ); > > CREATE TABLE host_events ( > ip IP4 NOT NULL REFERENCES ip_info(ip), > name VARCHAR > port INTEGER, > --other data > ); It would probably help to have an index on that column for all three tables, then I would wager using joins will be the speed winner. --------------------------------- Frank Wiles http://www.wiles.org ---------------------------------