My sample took somewhat longer to prepare then Edward's
and Gerd's
#1) to evaluate SQL statements use MgmtPortal/ Explorer/SQL and check the generated query plan.
#2) if you don't use special attributes to SELECT clause or sub-queries all SQL statements are strictly worked from left to right.
your first statement is ok for SQL your 2nd is just a fragment that I interpreted as to be a sub-query
Summary: they are not identical.
Now the example transformed for namespace SAMPLES to have 3 tables as A, B, and C:
sample.person A left join
sample.employee B on A.id = B.spouse
inner join sample.company C on B.company = C.id
Row count: 100
Query Plan:
Read extent bitmap Sample.Employee.$Employee, looping on ID.
Read extent bitmap Sample.Person.$Person, using the given ID.
For each row:
Read master map Sample.Company.IDKEY, using the given idkey value.
Output the row.
transformed to sub-queries:
(select A.id aid, b.id bid, b.company cid
from sample.person A
left join sample.employee B
on A.id = B.spouse)
inner join sample.company C
on cid = C.id
it is obviously identic ! just more expressive.
Row count: 100
Query Plan:
Read extent bitmap Sample.Employee.$Employee, looping on ID.
Read extent bitmap Sample.Person.$Person, using the given ID.
For each row:
Read master map Sample.Company.IDKEY, using the given idkey value.
Output the row.
the next LEFT_JOIN(A,INNER_JOIN(B.C)) requires immediate transformation
sample.person A left join
(select b.id as bid,c.id cid, b.spouse bsp
from sample.employee B
inner join sample.company C on B.company = C.id)
on A.id = bsp
Row count: 237 (!!!!)
Query Plan:
Read temp-file A, using the given VIEW column #3, and looping on VIEW counter.
For each row:
Generate a row padded with NULL for the view if no row qualified.
Output the row.
Read extent bitmap Sample.Employee.$Employee, looping on ID.
Read master map Sample.Company.IDKEY, using the given idkey value.
Increment view row counter.
Add a row to temp-file A, subscripted by VIEW column #3 and VIEW counter,
with node data of VIEW column #1 and VIEW column #2.
So both variants are possible though the result is different
HTH,
- Log in to post comments



Help > Install New Software