Re: strange explain - Mailing list pgsql-hackers

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


pgsql-hackers by date:

Previous
From: mlw
Date:
Subject: Re: pgaccess - the discussion is over
Next
From: Oleg Bartunov
Date:
Subject: Re: strange explain