0
votes

I have several tables with the same DIST and SORT keys, but with many different column names. When Redshift joins the tables, will I still get the benefit of a merge join, or does it depend on those columns having the exact same names?

For example, say I have tables a with DISTKEY and SORTKEY of user_id; and b with DISTKEY and SORTKEY of distinct_id, where distinct_id and user_id are the same data, they're just named differently.

SELECT a.user_id, a.col1, b.col2
FROM a JOIN b ON (a.user_id = b.distinct_id);

Will this result in a merge join?

1

1 Answers

1
votes

Yes! As long as the data in both tables are sorted.
You can use "Explain 'Your Query'" to check if the query performs Hash join or Merge join.