Re: Highly obscure and erratic - Mailing list pgsql-general

From Varun Kacholia
Subject Re: Highly obscure and erratic
Date
Msg-id 20020619144408.C6054@voxel.cse.iitb.ac.in
Whole thread Raw
In response to Re: Highly obscure and erratic  (Martijn van Oosterhout <kleptog@svana.org>)
Responses Re: Highly obscure and erratic  (Martijn van Oosterhout <kleptog@svana.org>)
List pgsql-general
> how does this differ from:
>
> select *
> from dbmedia
> where dbmedia.id=wdmedia.id
> and wdmedia.word='whatever'
> limit 200;

hey...
thanks for that..
that was surely better...
but now returning to the main point...
how can i execute the following query in the form above?

select * from dbmedia where id IN ((select ID from wdmedia where word='word1')
INTERSECT (select ID from wdmedia where word='word2') ...so on)


thanks again


> I think it's called "pilot error". Your query asked to run the subquery for
> each row in the outer query, so ofcourse you get a sequential scan. If what
> you wanted was an index scan then you should rewrite it as a join (as above)
> and use that.
>
> If you can prove that your EXISTS statement is equivalent to the JOIN for
> all different types of subqueries, perhaps it can be made automatic.
> --
> Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> > There are 10 kinds of people in the world, those that can do binary
> > arithmetic and those that can't.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly

--
------
Varun
  Best file compression around: "DEL *.*" = 100% compression


pgsql-general by date:

Previous
From: Oleg Bartunov
Date:
Subject: Re: Web application frameworks supporting PostgreSQL
Next
From: Thomas Beutin
Date:
Subject: Re: Problem with 'plpgsql'