Re: Strange query plan - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Strange query plan
Date
Msg-id 15318.991752154@sss.pgh.pa.us
Whole thread Raw
In response to Strange query plan  (Oleg Bartunov <oleg@sai.msu.su>)
Responses Re: Strange query plan  (Oleg Bartunov <oleg@sai.msu.su>)
List pgsql-hackers
Oleg Bartunov <oleg@sai.msu.su> 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


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Multiprocessor performance
Next
From: Oleg Bartunov
Date:
Subject: Re: Strange query plan