Re: strange explain
От | Oleg Bartunov |
---|---|
Тема | Re: strange explain |
Дата | |
Msg-id | Pine.GSO.4.44.0205131905300.683-100000@ra.sai.msu.su обсуждение исходный текст |
Ответ на | Re: strange explain (Tom Lane <tgl@sss.pgh.pa.us>) |
Список | pgsql-hackers |
Thanks Tom, On Mon, 13 May 2002, Tom Lane wrote: > Oleg Bartunov <oleg@sai.msu.su> writes: > > tour=# explain analyze select * from tours where > > ( operator_id in (2,3,4,5,7) and type_id = 2 ) or > > ( operator_id = 8 and type_id=4 ); > > > 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.26..0.26 rows=0 loops=1) > > > What does many 'type_idx' means ? > > Multiple indexscans. > > It looks to me like your WHERE clause is being flattened into > > ( operator_id = 2 and type_id=2 ) or > ( operator_id = 3 and type_id=2 ) or > ( operator_id = 4 and type_id=2 ) or > ( operator_id = 5 and type_id=2 ) or > ( operator_id = 7 and type_id=2 ) or > ( operator_id = 8 and type_id=4 ) > this is what I assume. > and then it has a choice of repeated indexscans on operator_id or > type_id. Depending on the selectivity stats it might pick either. > You might find that a 2-column index on both would be a win. > Yes, we've went exactly this way. I'm very exited how planner could be smart. When I played with the query and specify different values of type_id I notice it's chose plans depends on is value exists or not. > regards, tom lane > Regards, Oleg _____________________________________________________________ Oleg Bartunov, sci.researcher, hostmaster of AstroNet, Sternberg Astronomical Institute, Moscow University (Russia) Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ phone: +007(095)939-16-83, +007(095)939-23-83
В списке pgsql-hackers по дате отправления: