My query is related to JOIN logic where multiple tables or other database objects are involved.
Query 1: If there is piece of code containing join logic which involves multiple tables, which columns should we compare first in ON clause? Like, should we consider primary key columns, then foreign key columns and then other required columns Ex.:
c.dept_ID = d.dept_ID
AND d.product_ID = e.product_ID
AND ----
----
Does sequence of these comparisons really matter in case of query performance?
Query 2: Suppose Table alias c has 100 departments or Table alias d has 10 departments, will comparison sequence matters here? Like,
c.dept_ID = d.dept_ID or
d.dept_ID = c.dept_ID
Query 3: If we included view also along with multiple tables, should view related columns compared at last or first?