【发布时间】:2017-09-28 00:20:46
【问题描述】:
我的情况
我的 redshift 集群中有一些表,它们都分解为 order_id、shipment_id 或 shipping_item_id,具体取决于表的粒度。 order_id 是 shipping_id 上的一对多关系,shipment_id 是 shipemnt_item_id 上的一对多关系。
我的问题
我在 order_id 上分发,因此所有 shipping_id 和 shipping_item_id 记录应该在表中的相同节点上,因为它们按 order_id 分组。我的问题是,当我必须加入 shipping_id 或 shipping_item_id 时,redshift 会知道记录在同一个节点上,还是会因为它们没有加入 order_id 而广播这些表?
示例表
unified_order shipment_details
+----------+-------------+------------------+ +-------------+-----------+--------------+
| order_id | shipment_id | shipment_item_id | | shipment_id | ship_day | ship_details |
+----------+-------------+------------------+ +-------------+-----------+--------------+
| 1 | 1 | 1 | | 1 | 1/1/2017 | stuff |
| 1 | 1 | 2 | | 2 | 5/1/2017 | other stuff |
| 1 | 1 | 3 | | 3 | 6/14/2017 | more stuff |
| 1 | 2 | 4 | | 4 | 5/13/2017 | less stuff |
| 1 | 2 | 5 | | 5 | 6/19/2017 | that stuff |
| 1 | 3 | 6 | | 6 | 7/31/2017 | what stuff |
| 2 | 4 | 7 | | 7 | 2/5/2017 | things |
| 2 | 4 | 8 | +-------------+-----------+--------------+
| 3 | 5 | 9 |
| 3 | 5 | 10 |
| 4 | 6 | 11 |
| 5 | 7 | 12 |
| 5 | 7 | 13 |
+----------+-------------+------------------+
分布
distribution_by_node
+------+----------+-------------+------------------+
| node | order_id | shipment_id | shipment_item_id |
+------+----------+-------------+------------------+
| 1 | 1 | 1 | 1 |
| 1 | 1 | 1 | 2 |
| 1 | 1 | 1 | 3 |
| 1 | 1 | 2 | 4 |
| 1 | 1 | 2 | 5 |
| 1 | 1 | 3 | 6 |
| 1 | 5 | 7 | 12 |
| 1 | 5 | 7 | 13 |
| 2 | 2 | 4 | 7 |
| 2 | 2 | 4 | 8 |
| 3 | 3 | 5 | 9 |
| 3 | 3 | 5 | 10 |
| 4 | 4 | 6 | 11 |
+------+----------+-------------+------------------+
【问题讨论】:
-
给定您的查询示例,我在
shipment_details表中没有看到order_id,如果没有这样的列并且订单和发货之间的关系似乎是,order_id如何分配它仅保存在unified_order表中
标签: amazon-redshift