pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: nolan@celery.tssi.com
To: swampler@noao.edu
Cc: pgsql-performance@postgresql.org
Subject: Re: Improving a simple query?
Date: Sun, 13 Jul 2003 20:23:47 -0500 (CDT)
Message-ID: <20030714012347.18920.qmail@celery.tssi.com> (raw)
In-Reply-To: <20030713204610.GA18123@weaver.tuc.noao.edu>

> > Could you not rewrite this as a simple join though?
> 
> Hmmm, I don't see how.  Then again, I'm pretty much the village
> idiot w.r.t. SQL...
> 
> The inner select is locating a set of (2049) ids (actually from
> the same table, since 'attributes' is just a view into
> 'attributes_table').  The outer select is then locating all
> records (~30-40K) that have any of those ids.  Is that really
> something a JOIN could be used for?

This may be a question for SQL theoretists, but I don't think I've ever
run across a query with a 'where in' clause that couldn't be written
as a join.  I think linguistically 'where in' may even be a special 
case of 'join'.

Yet another question for the theoretists:  Would it be possible to optimize
a 'where in' query by rewriting it as a join?
--
Mike Nolan



view thread (8+ messages)  latest in thread

Message-ID: <20030714012347.18920.qmail@celery.tssi.com>
Permalink:  ../20030714012347.18920.qmail@celery.tssi.com/
Also on:    postgresql.org/message-id/20030714012347.18920.qmail@celery.tssi.com

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: nolan@celery.tssi.com, swampler@noao.edu
  Subject: Re: Improving a simple query?
  In-Reply-To: <20030714012347.18920.qmail@celery.tssi.com>
  References: <20030713204610.GA18123@weaver.tuc.noao.edu> <20030714012347.18920.qmail@celery.tssi.com>

* 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