Oleg Bartunov <oleg@sai.msu.su> writes:
> What's the difference for planner between 2 queries ?
> tour=# explain analyze select * from tours where
> ( operator_id in (2,3,4,5,7) and type_id = 2 );
> tour=# explain analyze select * from tours where
> ( operator_id in (2,3,4,5,7) and type_id = 4 ) or
> ( operator_id = 8 and type_id = 3);
The first one's already in normal form and doesn't need any more
flattening. I believe the system will consider a multiple indexscan
on operator_idx for it, but probably the cost estimator is concluding
that that's a loser compared to one indexscan using type_id = 2.
Without any info on the selectivity of these conditions it's hard to say
whether that's a correct choice or not.
regards, tom lane