On Tue, 21 Aug 2001, Joseph Shraibman wrote:

> Thank you, I was missing the parens.
> 
> If I do an explain I see:
> 
> ->  Index Scan using m_u_and_p_key on m  (cost=0.00..3035.22 rows=1363 width=12)
> 
> 
> even if I put a limit 1 on the select.  Why is that?

Is that the inner query (on the exists) or the entire explain?

I guess it'd be useful to see the whole query and explain and maybe
schema.

> Stephan Szabo wrote:
> > On Mon, 20 Aug 2001, Joseph Shraibman wrote:
> > 
> > 
> >>I want to select a boolean if there exists a row in another table that matches 
>this one. 
> >>So I did select ..., (select count(*) from table2 where ...) > 0 ...
> >>but that count(*) was taking forever.  I know there is a better way to do it, but 
>whenever 
> >>I try to use EXISTS I get a syntax error.  What is the proper way?
> >>
> > 
> > Hmm, on current sources I can do:
> > select ..., exists (select * from table2 where ...) from table1;
> > 
> > I don't know if that's new though...


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html

Reply via email to