sql - Does "Join" order will lead to different query performance -
this question has answer here:
- does sql join order affect performance? 6 answers
i have 2 tables (table1 table2), table2 larger table1.
script 1:
select t1.a, t2.b table1 t1 join table2 t2 on t1.pk = t2.fk script 2:
select t1.a, t2.b table2 t2 join table1 t1 on t1.pk = t2.fk does performance script #1 better script #2?
you using inner join answer no.
this produce same amount of data due join type, , joining same relations in both queries, identical.
it have been different if had used left join , because in left join, data master(left) table kept, , matching data details table(right) .
so if had used left join, , placed larger table on left side, query have produced more data , slower put larger table in right side.
Comments
Post a Comment