[HACKERS] Re: Strange query plan

2001-06-05 Thread Tom Lane

Oleg Bartunov [EMAIL PROTECTED] writes:
 The best plan I've got eliminating  IN predicate:
 select msg_prt.tid as mid from msg_prt
  where exists (select idx.tid from idx where msg_prt.tid=idx.tid
and idx.did=1 and idx.lid = 1207 and idx.lid=59587 )

Surely that returns zero rows?

regards, tom lane

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

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



[HACKERS] Re: Strange query plan

2001-06-05 Thread Tom Lane

Oleg Bartunov [EMAIL PROTECTED] writes:
 should be
 select msg_prt.tid as mid from msg_prt
  where exists (select idx.tid from idx where msg_prt.tid=idx.tid
and idx.did=1 and ( idx.lid = 1207 or idx.lid=59587 ));
 but this is not a big win.

Shouldn't be any win at all: the IN expression-list notation will get
translated to exactly that form.

 Anyway, what's about original query ?

IN/EXISTS subqueries suck.  This has been true for a long time and is
going to be true for a while longer, unless someone else fixes it before
I have a chance to look at it.  See if you can't rewrite your query as
a plain join.

regards, tom lane

---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly