Designing Redshift Tables with Distribution Styles and Sort Keys
This lesson explains how distribution styles, sort keys, compression and the schema decide where a table's rows are placed across nodes and how they are ordered on disk, which strongly affects query speed.
Learning outcomes
After completing this lesson, you will be able to:
- Choose a distribution style for each table.
- Choose sort keys and compression encodings.
- Design star schemas for analytical queries.
- Maintain tables with VACUUM and ANALYZE.
Distribution styles
Redshift spreads each table's rows across slices on its compute nodes, and the distribution style decides how. It matters most for joins: if matching rows of two tables are on different nodes, Redshift must move data across the network at query time. KEY distribution places rows with the same value of a chosen column on the same slice, so two large tables distributed on their join column join locally, called co-located. ALL places a full copy of the table on every node, so any join to it is local. That suits small dimension tables that change slowly, since every change is written to every node.
EVEN spreads rows round-robin, which balances storage for tables that are not joined on a particular key. AUTO, the default, lets Redshift choose and adjust the style as the table grows. The following table summarises the styles.
| Style | How rows are spread | Use for |
|---|---|---|
| AUTO | Redshift chooses and adjusts | When unsure |
| EVEN | Round-robin | Tables not joined on a key |
| KEY | Same key value on the same slice, so joins are co-located | Large tables joined on that column |
| ALL | A full copy on every node | Small, slowly changing dimension tables |
The following diagram shows where the rows of a sales schema sit on two compute nodes after the distribution styles are chosen to keep joins local.

Sort keys and encodings
A sort key determines the order in which a table's rows are stored on disk. When a query filters on the sort key column, for example a date range, the zone maps of sorted blocks have narrow, non-overlapping ranges, so Redshift skips most blocks without reading them. Sort keys are therefore usually placed on the columns used most often in range filters, typically dates. A compound sort key sorts by several columns in order and helps most when queries filter on the leading column; AUTO lets Redshift choose and adjust sort keys from the workload.
Compression encodings reduce the storage each column uses and therefore the I/O each query needs. Redshift chooses encodings automatically with ENCODE AUTO; common choices are AZ64 for numbers and dates and ZSTD or LZO for text. For semi-structured data, the SUPER data type stores JSON documents, which are queried with PartiQL, a SQL extension that navigates nested attributes and arrays, so JSON can be loaded without first flattening it into columns.
The following diagram shows how a sort key makes a Redshift table's zone maps selective.

Sort keys and encodings
Schema design
Redshift schemas are usually dimensional, because that design suits analytical queries. In a star schema, measurable events, such as sales, are stored in a central fact table, and descriptive attributes, such as product, customer and store details, are stored in dimension tables joined to it. Analysts filter and group by dimension attributes and aggregate fact measures.
Table design follows the schema. Large fact tables are distributed on the key of their most frequent join, so that join is co-located, and sorted on the date column used in most filters. Small dimension tables use ALL distribution so that every join to them is local. Denormalising a few frequently used attributes into the fact table, such as a product category, can avoid a join entirely for the most common queries, at the cost of some duplicated storage.
Fact or dimension?
Maintenance
Tables need maintenance as data changes. Deleted and updated rows leave space that is not reused immediately, and new rows are appended unsorted, which weakens the effect of sort keys. VACUUM reclaims that space and re-sorts rows, and ANALYZE refreshes the statistics the query planner uses to choose efficient plans. Redshift runs both automatically in the background when the warehouse is not busy, so manual runs are needed mainly after very large loads or deletes.
Redshift Advisor analyses the workload and recommends improvements, such as distribution and sort keys for specific tables. The system view SVV_TABLE_INFO shows each table's distribution skew, where some slices hold much more data than others and slow every query, and the proportion of unsorted rows, which shows whether a table needs vacuuming.
Table maintenance
Choosing distribution and sort keys
A warehouse has a 2-billion-row sales fact table, a 5-million-row customers table and a 500-row stores table. Most queries join sales to customers and filter on the last 30 days. The following table gives the design chosen for each table.
| Table | Distribution | Sort key | Reason |
|---|---|---|---|
| sales | KEY on customer_id | sale_date | Co-locates rows with matching customers; date filters skip blocks |
| customers | KEY on customer_id | — | Joins to sales without redistribution |
| stores | ALL | — | Small table copied to every node |
Before the change, the query plan showed DS_BCAST_INNER and DS_DIST_BOTH steps, meaning data was being moved between nodes for every join. After it, the join runs locally on each node. AUTO distribution and sort keys would make similar choices over time; explicit keys help when access patterns are well known.
Which distribution style suits a small dimension table?
Show answer
ALL, which copies the table to every node so joins need no data movement.
Exam Tips
Remember for the exam
- Large tables joined on the same column suit KEY distribution on that column.
- Small dimension tables suit ALL distribution.
- When unsure, use AUTO distribution and sort keys.
- Range filters on dates call for a sort key on the date column.
- Semi-structured JSON in Redshift calls for the SUPER type with PartiQL.