Let's say we have a query that essentially uses a join to combine 2 sets of records into 1. Now I need to duplicate the records, usually using a join. I believe option 1, in my opinion, is the best option for improving performance, but I wondered what SQL Query experts thought.
Basically, I know that the answer is "1". But, I also wonder if I could be wrong - is there a side to this I might miss?
(SQL Server) Here are my options.
pseudo code
Original request:
Select Name, Category from t1
Union
Select Name, Category from t2
Option 1)
Select Name, Category from t1
Inner Join (here)
Union
Select Name, Category from t2
Same inner Join (here)
Option 2)
Select * from (
Select Name, Category from t1
Union
Select Name, Category from t2
) t
(Inner Join Here)
source
share