Pro ยท Lesson 6 of 9
Start with AUTO distribution, sort, and encoding. Override them when you can name the join, the filter, and the skew.
Sign in to save your place.
Distribution is which waiter holds which orders. If two waiters must trade every plate to answer a question, dinner is slow. A sort key is the order of plates on one waiter's arm, so they can skip the ones that are obviously wrong. AUTO means you let Redshift watch the real questions and adjust those choices.
New tables should start with automatic table optimization: DISTSTYLE AUTO, SORTKEY AUTO, and ENCODE AUTO. Redshift can change distribution and sort as it sees queries. That is the 2026 default, not a hint you add after a crisis. Override it when you already know the join key and the filter, and you have looked at skew.
CREATE TABLE analytics.orders (
order_id BIGINT,
customer_id BIGINT,
ordered_at DATE,
amount NUMERIC(12, 2)
)
DISTSTYLE AUTO
SORTKEY AUTO
ENCODE AUTO;| Style | Rows go | Use when |
|---|---|---|
| AUTO | Redshift chooses, and can change | You are not sure yet |
| KEY | Rows with the same key share a slice | Large tables join on that key |
| EVEN | Rows are spread round-robin | There is no good join key |
| ALL | A full copy on every node | A small dimension that everyone joins |
Interleaved sort keys are a legacy option. Prefer a compound sort on the columns you filter in order, or leave sort on AUTO. A sort key helps a WHERE on a prefix of that key. It does not help a function wrapped around the column.
Key distribution on a column that is almost always the same value parks the rows on one slice. That slice works while the others wait. Check skew before you congratulate yourself on a key. ALL is only for tables small enough to copy everywhere. A fact table marked ALL will waste storage and load time.
Encoding compresses columns. AUTO picks encodings. Do not hand-tune encodings on day one. Vacuum and analyze are largely automatic on current RA3 and Serverless warehouses. You still need to know the words, because an old cluster or a deleted-row heavy table can need a manual vacuum. Design the table so the load does not depend on a weekly rescue.
Where rows live, what order they are stored in, and how they are compressed.
Step 1 of 3A DISTKEY on a join column puts matching rows on the same slice. DISTSTYLE ALL copies a small table everywhere. AUTO lets Redshift choose.
CREATE TABLE sales (...) DISTKEY(customer_id);
Step 2 of 3A sort key stores rows in order, so a date filter can skip whole blocks using zone maps.
CREATE TABLE events (...) SORTKEY(event_time);
Step 3 of 3Compression shrinks storage and the amount of data each query reads. ENCODE AUTO is the default.
SELECT "column", encoding FROM pg_table_def WHERE tablename = 'sales';
Create one table with AUTO for distribution, sort, and encoding. Write one sentence that says which column you would switch to KEY if the automatic choice proved wrong, and why that column is not a constant.
Checked against vendor documentation in October 2026. Screens and plan names still change, so confirm the control in your own instance.