Re: Improving a simple query? - Mailing list pgsql-performance

From nolan@celery.tssi.com
Subject Re: Improving a simple query?
Date
Msg-id 20030714012347.18920.qmail@celery.tssi.com
Whole thread Raw
In response to Re: Improving a simple query?  (Steve Wampler <swampler@noao.edu>)
List pgsql-performance
> > 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

pgsql-performance by date:

Previous
From: Hannu Krosing
Date:
Subject: Re: Improving a simple query?
Next
From: Chris Bowlby
Date:
Subject: Re: Improving a simple query?