Re: Highly obscure and erratic

From: Varun Kacholia <varunk(at)cse(dot)iitb(dot)ac(dot)in>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Highly obscure and erratic
Date: 2002-06-19 09:11:29
Message-ID: 20020619144408.C6054@voxel.cse.iitb.ac.in
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)svana(dot)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(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly

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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Beutin 2002-06-19 09:17:09 Re: Problem with 'plpgsql'
Previous Message Oleg Bartunov 2002-06-19 08:21:25 Re: Web application frameworks supporting PostgreSQL