Question 1 · choose 1
Two large Amazon Redshift tables, orders and order_items, are joined on order_id in most queries. Query plans show that much of the run time is spent redistributing rows between nodes. Which table design reduces this work?
- AUse EVEN distribution for both tables
- BUse KEY distribution on order_id for both tables
- CUse ALL distribution for both tables
- DUse KEY distribution on each table's own primary key column
Show the answer and why
AUse EVEN distribution for both tables
Incorrect
EVEN spreads rows round-robin regardless of values. It suits tables that do not take part in joins.
BUse KEY distribution on order_id for both tables
Correct
Distributing a pair of tables on their joining column puts matching rows on the same slice, so the join needs no redistribution.
CUse ALL distribution for both tables
Incorrect
ALL copies the whole table to every node, multiplying storage and load time. It is meant for relatively slow-moving tables, not two large ones.
DUse KEY distribution on each table's own primary key column
Incorrect
order_items would be distributed on its own key, not order_id, so rows with the same order_id would still sit on different slices.
Collocation is the point of KEY distribution: when both sides of a frequent join are distributed on the join column, each slice can join its own rows.
AWS documentation