pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Frank Wiles <frank@wiles.org>
To: Michael Artz <mlartz@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Subselect query enhancement
Date: Thu, 1 Feb 2007 12:20:45 -0600
Message-ID: <20070201122045.79ff29c8.frank@wiles.org> (raw)
In-Reply-To: <e9c163070702010842ja639378v75e8c0eb757d9b72@mail.gmail.com>
References: <e9c163070702010842ja639378v75e8c0eb757d9b72@mail.gmail.com>

On Thu, 1 Feb 2007 11:42:03 -0500
"Michael Artz" <mlartz@gmail.com> 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 <frank@wiles.org>
   http://www.wiles.org
 ---------------------------------




view thread (10+ messages)  latest in thread

Message-ID: <20070201122045.79ff29c8.frank@wiles.org>
Permalink:  ../20070201122045.79ff29c8.frank@wiles.org/
Also on:    postgresql.org/message-id/20070201122045.79ff29c8.frank@wiles.org

 · 

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-performance@postgresql.org
  Cc: frank@wiles.org, mlartz@gmail.com
  Subject: Re: Subselect query enhancement
  In-Reply-To: <20070201122045.79ff29c8.frank@wiles.org>

* 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