> EXPLAIN
> 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);
> NOTICE:  QUERY PLAN:
> 
> Index Scan using type_idx, type_idx, type_idx, type_idx, type_idx, type_idx on tours 
> (cost=>
> 0.00..12.25 rows=1 width=1091) (actual time=0.27..0.27 rows=0 loops=1)
> Total runtime: 0.44 msec

Actually this plan looks very strange to me. One would expect it to only use 
type_idx twice (in lack of a better index (type_id, operator_id)). 
Fetch all rows with type_id=4 and then filter the result on operator_id in (...), 
then do type_id=3 and filter operator_id=8.
Seems there is room for another performance improvement here :-)

Andreas

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Reply via email to