Controlling join order with parenthesis
Controlling join order with parenthesis
От:
"Marc Mamin" <M.Mamin@intershop.de>
Дата:
Hello, According to the documentation, I thought it was possible to force given join orders with parenthesis. But in this small example, this seems to have no effect; With the first query, I'd expected to see t3 in the Merge Right Join but both queries return the same query plan . I'm missing a point ? (Postgres 8.3) create temp table t1(i int); create temp table t2(i int); create temp table t3(i int); select * from ( ( t1 LEFT OUTER JOIN t2 on (t1.i=t2.i) ) LEFT OUTER JOIN t3 on (t2.i=t3.i)) select * from ( t1 LEFT OUTER JOIN (t2 LEFT OUTER JOIN t3 on (t2.i=t3.i) ) on (t1.i=t2.i) ) Merge Right Join (cost=506.24..6206.24 rows=345600 width=12) Merge Cond: (t2.i = t1.i) -> Merge Left Join (cost=337.49..781.49 rows=28800 width=8) Merge Cond: (t2.i = t3.i) -> Sort (cost=168.75..174.75 rows=2400 width=4) Sort Key: t2.i -> Seq Scan on t2 (cost=0.00..34.00 rows=2400 width=4) -> Sort (cost=168.75..174.75 rows=2400 width=4) Sort Key: t3.i -> Seq Scan on t3 (cost=0.00..34.00 rows=2400 width=4) -> Sort (cost=168.75..174.75 rows=2400 width=4) Sort Key: t1.i -> Seq Scan on t1 (cost=0.00..34.00 rows=2400 width=4) best regards, Marc Mamin
Re: Controlling join order with parenthesis
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
"Marc Mamin" writes: > According to the documentation, I thought it was possible to force given > join orders with parenthesis. You can do that if you dial down join_collapse_limit. Bear in mind that leaves you *solely* responsible for picking an intelligent join order. I wouldn't recommend it as a production setting. regards, tom lane