AWS › Amazon Redshift & Data Warehousing
How does distribution style affect query performance in Redshift?
IntermediateAnswer
Distribution style determines how Redshift spreads a table's rows across the multiple compute nodes in a cluster, with options including KEY distribution which groups rows sharing the same value in a specific column onto the same node to speed up joins on that column, ALL distribution which copies the entire table to every node for small frequently joined tables, and EVEN distribution which spreads rows evenly regardless of their values, and choosing the right style for each table significantly affects how efficiently join queries execute.
CREATE TABLE orders (
order_id INT,
customer_id INT,
order_total DECIMAL
) DISTSTYLE KEY DISTKEY(customer_id);Real-world example A data warehousing team sets the distribution key on both their orders and customers tables to customer_id, ensuring that related rows from both tables end up on the same compute node, which makes joining them together far more efficient.