I am developing an application with backend C#
and it has one feature that generates dynamic SQL
queries on tab change. The tab provides the input for the dynamic queries. For the time being, this is how it generates:
For Two Tables:
table1 q,table2 r where q.col1 = r.col1 AND r.col1 = q.col1
q.col1 = r.col1 AND r.col1 = q.col1 -- The joins
For Four Tables:
table1 q,table2 r,table3 s,table4 v
where r.col1 = q.col1 AND s.col1 = q.col1
AND v.col1 = q.col1 AND q.col1 = r.col1
AND s.col1 = r.col1 AND v.col1 = r.col1
AND q.col1 = s.col1 AND r.col1 = s.col1
AND v.col1 = s.col1 AND q.col1 = v.col1
AND r.col1 = v.col1 AND s.col1 = v.col1
r.col1 = q.col1 -- The joins
AND r.col1 = s.col1
AND r.col1 = v.col1
AND s.col1 = q.col1
AND s.col1 = r.col1
AND s.col1 = v.col1
AND q.col1 = r.col1
AND q.col1 = s.col1
AND q.col1 = v.col1
AND v.col1 = q.col1
AND v.col1 = r.col1
AND v.col1 = s.col1
Based on each table, it creates all possible joins for the table and it works. Now my question is, will these joins have any impact on the performance later as it creates all possible joins using aliases that has been used for the tables?