Re: Subqueries and the optimizer

From: Mike Mascari <mascarm(at)mascari(dot)com>
To: Dmitri Bichko <dbichko(at)genpathpharma(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Subqueries and the optimizer
Date: 2003-05-19 21:21:43
Message-ID: 3EC94AE7.2040508@mascari.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Dmitri Bichko wrote:
> I wish it were as easy as a join - the query is much simplified for the
> purpose of the example, in reality the subselect is more complicated and
> includes a GROUP BY (which, at least as far as I know, makes subqueries
> the only way of doing this).
>
> Thanks anway, guess I'll wait for 7.4 with this (and just split them up
> into two queries for the time being),

Did you try a correlated subquery using EXISTS? You can make that
subquery as complicated as you want. The semantics between IN and
EXISTS vary though in the prescence of NULLs.

SELECT blast_id
FROM genes
WHERE blast_batch_id = 2 AND EXISTS (
SELECT 1
FROM ll_out_mm
WHERE ll_out_mm.locusid = genes.locus_id AND
...
};

Mike Mascari
mascarm(at)mascari(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jim C. Nasby 2003-05-19 21:37:08 Re: ERROR: Memory exhausted in AllocSetAlloc(188)
Previous Message Sarah 2003-05-19 20:59:00 plpgsql error?