Re: IN vs = - Mailing list pgsql-novice

From Tom Lane
Subject Re: IN vs =
Date
Msg-id 29955.1233005605@sss.pgh.pa.us
Whole thread Raw
In response to IN vs =  ("Lukas" <lukas@fmf.vtu.lt>)
Responses Re: IN vs =  ("Lukas" <lukas@fmf.vtu.lt>)
List pgsql-novice
"Lukas" <lukas@fmf.vtu.lt> writes:
>  I would like to ask, what is the main difference between operators IN and
> '='.
>  Then I use operator IN in JOIN it gives me much worse time (in my example
> ~3000ms) at the same time '=' gives 30ms!
>  But the most interesting think is that at the begging (when DB was
> smaller) worked at the same speed as '=', why?

Was it also on a different PG release back then?

> LEFT JOIN b_mokejimu_sudengimai ON (mok_id IN (ms_mokejimas, ms_padengimas))

>                                 Join Filter: (b_mokejimai.mok_id = ANY
> (ARRAY[b_mokejimu_sudengimai.ms_mokejimas,
> b_mokejimu_sudengimai.ms_padengimas]))

The latest 8.2.x and 8.3.x releases contain a patch that avoids using
this construct when there are variables on the right-hand side; I think
that's your problem.

(FWIW, most people would probably say that having to write a join like
this suggests you need to refactor your database structure...)

            regards, tom lane

pgsql-novice by date:

Previous
From: "Lukas"
Date:
Subject: IN vs =
Next
From: Robert Schnabel
Date:
Subject: Re: postgres.exe 100% CPU but no I/O