Re: Subqueries and the optimizer - Mailing list pgsql-general

From Mike Mascari
Subject Re: Subqueries and the optimizer
Date
Msg-id 3EC94AE7.2040508@mascari.com
Whole thread Raw
In response to Re: Subqueries and the optimizer  ("Dmitri Bichko" <dbichko@genpathpharma.com>)
List 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@mascari.com




pgsql-general by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: Subqueries and the optimizer
Next
From: Alvaro Herrera
Date:
Subject: Re: Subqueries and the optimizer