HomeInterview QuestionsAre distribution keys short or long in Redshift?

Are distribution keys short or long in Redshift?

🟡 Medium Conceptual Mid level
1Times asked
Jul 2026Last seen
Jul 2026First seen

💡 Model Answer

In Redshift, a distribution key (DISTKEY) determines how rows are distributed across the cluster’s slices. The key can be a single column (short key) or a composite of multiple columns (long key). Choosing the right key is critical for performance:

  • Short key (single column) – Simpler to manage and often used when the column has high cardinality and is frequently used in joins. It reduces the chance of data skew.
  • Long key (composite) – Useful when a single column does not provide enough uniqueness. A composite key can balance data more evenly but may increase the size of the key and the cost of hashing.

Guidelines:

  1. High cardinality – Prefer keys with many distinct values to avoid skew.
  2. Join column – Pick a column that appears in join predicates; this keeps related rows on the same slice.
  3. Avoid low‑cardinality columns – Columns like gender or status can cause skew.
  4. Consider query patterns – If you often filter by a combination of columns, a composite key may be beneficial.
  5. Test with sample data – Use the ANALYZE command to see distribution statistics.

In practice, many teams start with a short key on a high‑cardinality column and only move to a long key if skew or performance issues arise.

This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.

🎤 Get questions like this answered in real-time

Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers on a discreet on-screen overlay.

Get Assisting AI — Starts at ₹500