当两个表具有相同的 dist 和 sort 键但列名不同时,Redshift 是否执行合并连接?

Does Redshift perform a merge join when two tables have the same dist and sort keys, but the column names are different?

我有几个表具有相同的 DIST 和 SORT 键,但有许多不同的列名。当 Redshift 连接表时,我是否仍会获得合并连接的好处,还是取决于那些具有完全相同名称的列?

例如,假设我有表 a,其中 DISTKEYSORTKEYuser_id;和 bDISTKEYSORTKEY of distinct_id,其中 distinct_iduser_id 是相同的数据,它们只是命名不同。

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

这会导致合并连接吗?

是的!只要两张表的数据都是有序的。
可以用"Explain 'Your Query'"检查查询是执行Hash join还是Merge join。